Remove duplicate elements: Difference between revisions
→{{header|AppleScript}}
Line 131:
-- nubBy :: (a -> a -> Bool) -> [a] -> [a]
on nubBy(fnEq, xxs)
script mf
-- notEq :: a -> Bool▼
on notEq(a)▼
set mf to mReturn(my closure's fnEq)▼
not (mf's lambda(a, my closure's x))▼
end notEq▼
end script
set lng to length of xxs
if lng > 1 then
Line 136 ⟶ 145:
set xs to items 2 thru -1 of xxs
{x} & nubBy(fnEq, filter(mClosure(
else
xxs
end if
end nubBy
▲ -- notEq :: a -> Bool
▲ on notEq(a)
▲ set mf to mReturn(my closure's fnEq)
▲ not (mf's lambda(a, my closure's x))
▲ end notEq
end script
|