// k adverbs // [[1 2][3 4][5 6]] [* +] each // 2 [3 4 5] [[!:] infra] each ; each [+:] dip [i] ,. map ; // xs x [p] each\ ; each\ { [a b p] a a #: b ,: # pair p each } ; // x xs [p] each/ ; each/ { [a b p] b a [swap p i] each\ } ; // 0 [1 + 5 !] converge // 9 [[0 0 0 1 1 4 2 2 6 6]] converge! ; converge { [a p] a a a p i p converge. } ; ; converge. { [a b c p] c [a b] _in [c] [a c c p i p _z] if } ; ; converge! { [a p] [a] a a a p i p converge!. } ; ; converge!. { [s a b c p] c [a b] _in [s] [s c ,: , a c c p i p _z] if } ; // 0 [[1 2 3]] [+] over // 3 [[1 2 3][4 5 6]] [+ *] over // [] [[[1 2][3 4 5]]] [,] over ; over { [s a p] a [s a +: p over.] [s] if } ; ; over. { [s a p] a [s a uncons [cons i p i] dip p _z] [s] if } ; ; over! { [s a p] S/ s a +: p over!. S\ 1 _. } ; ; over!. { [s a p] a [s s a uncons [cons i p i] dip p _z] [s] if } ; ; under [swap] dip over ; ; under! [swap] dip over! ; // 5 2 [3 +] do // also finite-state machine ; do { [a n p] n [a p i n pred p do] [a] if } ; ; do! { [a n p] S/ a n p do!. S\ } ; ; do!. { [a n p] n [a a p i n pred p _z] [a] if } ; // 5 [0 >] [pred] while ; while { [a q p] a q i [a p i q p _z] [a] if } ; ; while! { [a q p] S/ a q p while!. S\ } ; ; while!. { [a q p] a q i [a a p i q p _z] [a] if } ; // 12 [2 5 7 3] [-] prior ; prior { [a b p] b @: [a] [b [[a] b p prior.] [b] if] if 1 _. } ; ; prior. { [s b p] b #: 1 > [s 2 b # 1 b _ [|: p infra ,] dip p _z] [s] if } ; // [1 2 3] [+] reduce // [1 2 3] [+] scan ; reduce { [a p] a prototype a ,: p over } ; ; scan { [a p] a prototype a ,: p over! } ; ; flatten ,: [] swap [,] over ; ; raze [flatten] converge ;