Description Usage Arguments Examples
The order of arguments position is different from that of Haskell's because it is easy for magrittr's pipe to pass a lazy stream as the first argument.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | lfoldl(x, f, init)
lfoldl1(x, f)
lfoldl_dash(x, f, init)
lfoldl1_dash(x, f)
lfoldr(x, f, init)
lfoldr1(x, f)
lscanl(x, f, init)
lscanl1(x, f)
lscanr(x, f, init)
lscanr1(x, f)
lunfold_haskell(x, g)
lunfoldl(x, f_pred, f_map, f_gen)
lunfoldr(x, f_pred, f_map, f_gen)
|
x |
a lazy stream |
f |
function who must takes two areguments |
init |
initial value if needed |
g |
a function that takes one argument and returns lcons or lempty |
f_pred |
a predicate function for unfold |
f_map |
a mapping function for unfold |
f_gen |
a generating function for unfold |
1 2 3 4 5 6 7 8 9 10 11 12 | lfoldl(1%..%10, `+`, 0) # => 55
lfoldl(1%..%10, function(x,y) paste0("(",x,"+",y,")"), 0)
# => "((((((((((0+1)+2)+3)+4)+5)+6)+7)+8)+9)+10)"
lfoldr(1%..%10, function(x,y) paste0("(",x,"+",y,")"), 0)
# => "(1+(2+(3+(4+(5+(6+(7+(8+(9+(10+0))))))))))"
lscanl(1%..%10,`+`, 0) # => llist(0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55)
## library("magrittr")
## liota() %>% ltake(10) %>% lfoldl1(`+`) # => 45
lunfold_haskell(0, function(x) if (x >= 10) lempty else lcons(x, x + 1))
lunfoldl(1, function(x) x > 10, function(x) x ^ 2, function(x) x + 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.