drop-while

drop-while

(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....

March 24, 2024 · 1 min
take-while

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....

September 9, 2023 · 1 min
remove

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

August 12, 2023 · 1 min
map

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....

July 1, 2023 · 1 min
map

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....

June 18, 2023 · 1 min
filter

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 ↩︎

June 11, 2023 · 1 min