(drop-while f coll) The drop-while function takes 2 arguments : f: a function that takes one argument x and returns TRUE or FALSE coll: a collection of items drop-while starts from the first item in the collection and ignore all successive elements for which f returns TRUE. As soon as f returns FALSE, the element and all elements following it, are added to the result. Unlinke the remove function drop-while doesn’t got through all the elements in the collection....
take-while
(take-while f coll) The take-while function takes 2 arguments : f: a function that takes one argument x and returns TRUE or FALSE coll: a collection of items take-while starts from the first item in the collection and returns the sequence of all successive elements for which f returns TRUE. As soon as f returns FALSE, take-while terminates and does not process any further elements. Unlike the filter function, take-while doesn’t go through all the elements in the collection....
remove
(remove f coll) The remove function takes 2 arguments : f: a function that takes one argument x and returns TRUE or FALSE coll: a collection of items filter returns a sequence of items from the collection for which f returns FALSE (it’s the opposite of filter) In the above animation, f returns TRUE when the item is a triangle or when it is blue. remove
reduce
(reduce f val coll) In this animation, the function reduce takes 3 arguments: f: a function that takes two arguments and returns a value val: an initial value coll: a collection of items reduce calls function f with val and the first item in coll. The value returned by f is then used to call f again, but this time with the second item in coll. The value returned by f is then used to call f again, but this time with the third item in coll … and so on until all items in coll have been used....
map
(map f coll) In this animation, the function map takes 2 arguments: f: a function that takes one argument and returns a value coll: a collection of items map returns a new list made of the result of f applied to each item from the collection. Consequently the list returned by map always contains the same number of items than the collection passed as argument. In the above animation, f paints into orange each item passed to it....
filter
(filter f coll) The filter function takes 2 arguments : f: a function that takes one argument x and returns TRUE or FALSE 1 coll: a collection of items filter returns a sequence of items from the collection for which f returns TRUE (it’s the opposite of remove). In the above animation, f returns TRUE when the item is a triangle or when it is blue. filter such function is called a predicate ↩︎