Examples to implement - roboguy13/suslik GitHub Wiki

Symbol Meaning
:clock9: Ongoing implementation
:heavy_check_mark: Implemented
:question: Cannot currently implement or cannot figure out how to implement yet
Name Status
constMap :clock9:
filter_gt_9 :clock9:
filter :clock9:
concat :clock9:
concatMap :clock9:
replicate :clock9:
zip :clock9:
unzip :clock9:
pairwiseSum :clock9:
iterateN :clock9:
foldBinTree :clock9:
foldRoseTree :clock9:

constMap

Similar to map (here called constrained_list), but puts replaces the contents of each list item with the given constant. A special case of this, to get started, would be zeroMap which replaces every list item with 0. See the map example for help.

filter_gt_9

Remove all items from the given list which are <= 9.

filter

Generalize filter_gt_9 to work with arbitrary (pure) predicate lambdas, rather than just the condition "<= 9".

concat

Join two layers of a nested list. For example, to use a non-SuSLik notation, the list [1,2,3], [4,5,6](/roboguy13/suslik/wiki/1,2,3],-[4,5,6) becomes [1,2,3,4,5,6]

concatMap

A map followed by a concat. Try to implement by hand and then try to implement by re-using concat and map.

replicate

Create a list with the given int repeated n times (for a given n).

zip

Given two lists, produce a list of pairs where the first item of each pair is from the first list and the second item is the corresponding item from the second list.

unzip

Given a list of pairs, produce two lists: one containing all the first items in the pairs and another one containing all the second items.

pairwiseSum

Given two lists, produce a list where the first item of each pair is added to the second item. Try to do this by re-using map and zip.

iterateN

Start with an initial "seed" value and apply a function to it to is n times for a given n, constructing a list of the resulting values along the way. This is a Haskell example of this though, in our case, we generate a finite list (of length n).

This is a special case of an unfold.

foldBinTree

Like fold, but for binary trees.

foldRoseTree

Like fold, but for rose trees.