{{ message }}

Instantly share code, notes, and snippets.

llelf/folds

Last active Sep 14, 2021
 what k4/k7 k9 example result --------------------------------------------------------------------------------- each-left a f\:b a f\:b (!3)*\:!2 (0 0;0 1;0 2) each-right a f/:b a f/:b (!3)*/:!2 (0 0 0;0 1 2) fold f/v f/v */6 7 42 fold w/initial a f/v a f/v 7*/11 13 1001 scan f\v f\v -\1 1 1 1 0 -1 scan w/initial a f\v a f\v 3-\1 1 1 2 1 0 fixpoint f/x f/:x (1+1%)/:1 1.618034 fixpoint scan f\x f\:x 3 4 2 1\:0 0 3 1 4 do-n n f/x (n;f)/:x (2;"ha",)/:"!" "haha!" do-n scan n f\x (n;f)\:x (3;{x*x})\:2 2 4 16 256 while c f/x (c;f)/:x (1e3>;2*)/:1 1024 while scan c f\x (c;f)\:x (5 mod;2+)\:4 4 6 8 10 e.g. flatten ,// ,//: ,//:((1;2 3);4) 1 2 3 4 sv b/:v b/v 16/2 10 42 vs b\:x b\x 2\42 1 0 1 0 1 0

llelf commented May 21, 2020 • edited

 `````` i:&'3={y*1+x}\'" "=b:2_(#')#0:"folds.txt";&/(~/\$.')'(i^'b)[;3 4] ``````

ktye commented Sep 28, 2020

 flatten could use a better example. if you do k9 ,// the result is the same (no fixed-point involved). how about: ,//:((1;2 3);4)

llelf commented Oct 12, 2020

 @ktye yes! thanks