11Produces the list `a` in reverse order.
52Produces a `++list` whose type is a fork of all the contained types in the
53list `a`. Used when you want to make all the types of the elements of a list the same.
71 |% +- $ ?:(*? ~ [i=(snag 0 a) t=$])
80 [i=1 t=[i=97 t=[i=2 t=[i=98 t=[i=[~ u=10] t=~]]]]]
85 [i=1 t=[i=2 t=[i=3 t=~]]]
96Produces the length of any `++list` `a` as an atom.
124 > (lent (limo [1 2 3 4 ~]))
126 > (lent (limo [1 'a' 2 'b' (some 10) ~]))
136Produces the index of the first occurrence of `++list` `nedl` in
137`++list` `hstk` as the `++unit` of an atom.
149The `++unit` of an atom.
154 ++ find :: first index
156 |= {nedl/(list) hstk/(list)}
161 ?: |(?=($~ n) ?=($~ h))
167 ^$(i +(i), hstk +.hstk)
173 > (find [3]~ ~[1 2 3])
175 > (find [4]~ ~[1 2 3])
177 > (find ['a']~ "cbabab")
179 > (find "ab" "cbabab")
189Produces the indices of all occurrences of `++list` `nedl` in
190`++list` `hstk` as a `++list` of atoms.
207 ++ fand :: all indices
209 |= {nedl/(list) hstk/(list)}
215 ?: |(?=($~ n) ?=($~ h))
219 ^$(i +(i), hstk +.hstk, fnd [i fnd])
221 ^$(i +(i), hstk +.hstk)
227 > (fand [3]~ ~[1 2 3])
229 > (fand [4]~ ~[1 2 3])
231 > (fand ['a']~ "cbabab")
233 > (fand "ab" "cbabab")
243Computes the Boolean logical "and" on the results of gate `b` applied to each individual element in `++list` `a`.
262 |* {a/(list) b/$-(* ?)}
272 > =a |=(a/@ (lte a 1))
273 > (levy (limo [0 1 2 1 ~]) a)
275 > =a |=(a/@ (lte a 3))
276 > (levy (limo [0 1 2 1 ~]) a)
286Computes the Boolean logical "or" on the results of applying [gate]() `b` to every element of [`++list`]() `a`.
300 |* {a/(list) b/$-(* ?)}
309 > =a |=(a=@ (gte a 1))
310 > (lien (limo [0 1 2 1 ~]) a)
312 > =a |=(a=@ (gte a 3))
313 > (lien (limo [0 1 2 1 ~]) a)
323Turns a null-terminated tuple into a [`++list`]().
328`a` is a null-terminated tuple.
341 |% +- $ ?~(a ~ ?:(_? i=-.a t=$ $(a +.a)))
349 [i=1 t=[i=2 t=[i=3 t=~]]]
358Passes each member of `++list` `a` to gate `b`, which must produce a
359`++unit`. Produces a new list with all the results that do not produce
367`b` is a gate that produces a unit.
377 ++ murn :: maybe transform
379 |* {a/(list) b/$-(* (unit))}
390 > =a |=(a=@ ?.((gte a 2) ~ (some (add a 10))))
391 > (murn (limo [0 1 2 3 ~]) a)
401Removes elements from list `c` beginning at inclusive index `a`, removing `b` number of elements.
418 |* {{a/@ b/@} c/(list)}
419 (weld (scag a c) (slag (add a b) c))
424 > (oust [4 5] "good day, urbit!")
426 > (oust [2 2] (limo [1 2 3 4 ~]))
436Replicate: produces a `++list` containing `a` copies of `b`.
462 ~[%a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a]
464 ~[~s1 ~s1 ~s1 ~s1 ~s1]
465 > `@dr`(roll (reap 5 ~s1) add)
475Right fold: moves right to left across a `++list` `a`, recursively slamming
476a binary gate `b` with an element from `a` and an accumulator, producing
477the final value of the accumulator.
487The accumulator, which is a noun.
492 ++ reel :: right fold
494 |* {a/(list) b/_|=({* *} +<+)}
504 > =sum =|([p=@ q=@] |.((add p q)))
505 > (reel (limo [1 2 3 4 5 ~]) sum)
507 > =a =|([p=@ q=@] |.((sub p q)))
508 > (reel (limo [6 3 1 ~]) a)
510 > (reel (limo [3 6 1 ~]) a)
521Left fold: moves left to right across a list `a`, recursively slamming a
522binary [gate]() `b` with an element from the [`++list`]() and an accumulator,
523producing the final value of the accumulator.
528`b` is a binary [gate]().
533The accumulator, which is a [noun]().
540 |* [a=(list) b=_|=([* *] +<+)]
544 $(a t.a, b b(+<+ (b i.a +<+.b)))
549 > =sum =|([p=@ q=@] |.((add p q)))
550 > (roll (limo [1 2 3 4 5 ~]) sum)
552 > =a =|([p=@ q=@] |.((sub p q)))
553 > (roll (limo [6 3 1 ~]) a)
556 > (roll (limo [1 3 6 ~]) a)
566Accepts an atom `a` and [list]() `b`, producing the first `a` elements of
567the front of the list.
577A list of the same type as `b`.
586 ?: |(?=(~ b) =(0 a)) ~
587 [i.b $(b t.b, a (dec a))]
592 > (scag 2 (limo [0 1 2 3 ~]))
594 > (scag 10 (limo [1 2 3 4 ~]))
595 [i=1 t=[i=2 t=[i=3 t=[i=4 t=~]]]]
604Separates a `++list` `a` into two lists - Those elements of `a` who produce
605true when slammed to gate `b` and those who produce `%.n`.
610`b` is a gate that accepts one argument and produces a loobean.
622 |* {a/(list) b/$-(* ?)}
626 ?:((b i.a) [[i.a p.c] q.c] [p.c [i.a q.c]])
633 > =a |=(a/@ (gth a 1))
634 > (skid (limo [0 1 2 3 ~]) a)
635 [p=[i=2 t=[i=3 t=~]] q=[i=0 t=[i=1 t=~]]]
644Cycles through the members of a list `a`, passing them to a gate `b` and
645producing a list of all of the members that produce `%.y`. Inverse of
651`b` is a gate that accepts one argument and produces a boolean.
663 |* {a/(list) b/$-(* ?)}
667 ?:((b i.a) [i.a $(a t.a)] $(a t.a))
673 > =a |=(a/@ (gth a 1))
674 > (skim (limo [0 1 2 3 ~]) a)
684Cycles through the members of `++list` `a`, passing them to a gate `b`.
685Produces a list of all of the members that produce `%.n`. Inverse of
691`b` is a gate that accepts one argument and produces a loobean.
696A list of the same type as `a`.
703 |* {a/(list) b/$-(* ?)}
707 ?:((b i.a) $(a t.a) [i.a $(a t.a)])
713 > =a |=(a/@ (gth a 1))
714 > (skip (limo [0 1 2 3 ~]) a)
724Accepts an atom `a` and list `b`, producing the remaining elements from
735A list of the same type as `b`.
752 > (slag 2 (limo [1 2 3 4 ~]))
754 > (slag 1 (limo [1 2 3 4 ~]))
755 [i=2 t=[i=3 t=[i=4 t=~]]]
764Accepts an atom `a` and a `++list` `b`, producing the element at the index
765of `a`and failing if the list is null. Lists are 0-indexed.
775Produces an element of `b`, or crashes if no element exists at that index.
795 > (snag 0 `(list @ud)`~[1 2 3 4])
805Quicksort: accepts a `++list` `a` and a gate `b` which accepts two nouns and
806produces a loobean. `++sort` then produces a list of the elements of `a`,
807sorted according to `b`.
812`b` is a gate that accepts two nouns and produces a boolean.
822 ++ sort !. :: quicksort
824 |* {a/(list) b/$-([* *] ?)}
829 $(a (skim t.a |=(c/_i.a (b c i.a))))
831 [i.a $(a (skim t.a |=(c/_i.a !(b c i.a))))]
837 > =a =|({p=@ q=@} |.((gth p q)))
838 > (sort (limo [0 1 2 3 ~]) a)
848Similar to `substr` in Javascript: extracts a string infix, beginning at
849inclusive index `a`, producing `b` number of characters.
859A list of the same type as `c`.
865 |* {{a/@ b/@} c/(list)}
866 (scag +<-> (slag +<-< c))
872 > (swag [2 5] "roly poly")
874 > (swag [2 2] (limo [1 2 3 4 ~]))
884Accepts a `++list` `a` and a gate `b`. Produces a list with the gate applied
885to each element of the original list.
902 |* {a/(list) b/$-(* *)}
905 [i=(b i.a) t=$(a t.a)]
911 > (turn (limo [104 111 111 110 ~]) @t)
913 > =a |=(a/@ (add a 4))
914 > (turn (limo [1 2 3 4 ~]) a)
922Gate to list, with state
924Accepts a `++list` `a`, a gate `b`, and some state `c`. Produces a list with
925the gate applied to each element of the original list. `b` is called with
926a tuple -- the head is an element of `a` and the tail is the state `c`, and
927should produce a tuple of the transformed element and the (potentially
948 |* {a/(list) b/_|=({* *} [** +<+]) c/*}
949 :: ?< ?=($-([_?<(?=($~ a) i.a) _c] [* _c]) b)
954 [i=-.v t=$(a t.a, c +.v)]
960A trivial example -- does nothing with the state:
962 > %^ spin (limo ~[4 5 6])
967Create a list of pairs, `p` as the index and `q` as the list element:
969 > %^ spin (limo ~[4 5 6])
970 |=({n/@ a/@} [`(pair)`[a n] +(a)])
972 ~[[p=0 q=4] [p=1 q=5] [p=2 q=6]]
974Create 10 random numbers less than `10`:
976 > %^ spin (reap 10 0)
977 |=({n/@ rng/_og} (rads:rng 10))
979 ~[5 5 9 4 1 7 9 9 9 6]
983`(~(rads og eny) 2)` creates a random number less than `2`, seeding the RNG
984with entropy (`eny`). The head of the product is the random number, the tail
985is the continuation of the RNG.
992Gate to list, with state
994Accepts a `++list` `a` and a gate `b`. `c` is internal state, initially
995derived by *bunting* the tail of the sample of gate `b`, instead of
996being passed in explicitly as in `++spin`. Produces a list with the
997gate applied to each element of the original list. `b` is called with a tuple
998-- the head is an element of `a` and the tail is the state `c`, and should
999produce a tuple of the transformed element and the (potentially modified)
1018 |* {a/(list) b/_|=({* *} [** +<+])}
1024 [i=-.v t=$(a t.a, c +.v)]
1030Create a list of pairs, `p` as the index and `q` as the list element:
1032 > %+ spun (limo ~[4 5 6])
1033 |=({n/@ a/@} [`(pair)`[a n] +(a)])
1034 ~[[p=0 q=4] [p=1 q=5] [p=2 q=6]]
1036Join two lists into a list of pairs, `p` from `l` and `q` from the sample:
1038 > =l (limo ~[7 8 9])
1039 > %+ spun (limo ~[4 5 6])
1040 |=({n/@ a/@} [`(pair)`[(snag a l) n] +(a)])
1041 ~[[p=7 q=4] [p=8 q=5] [p=9 q=6]]
1050Concatenate two `++list`s `a` and `b`.
1055`a` and `b` are lists.
1060 ++ weld :: concatenate
1062 |* {a/(list) b/(list)}
1063 => .(a ^.(homo a), b ^.(homo b))
1073 ~[~~u ~~r ~~b ~~i ~~t]
1074 > (weld (limo [1 2 ~]) (limo [3 4 ~]))
1084Concatenate two `++list`s `a` and `b` without losing their type information
1102 ++ welp :: perfect weld
1115 > (welp "foo" "bar")
1117 ~zod/arvo=/hoon/hoon> (welp ~[60 61 62] ~[%a %b %c])
1118 [60 61 62 %a %b %c ~]
1119 ~zod/arvo=/hoon/hoon>? (welp ~[60 61 62] ~[%a %b %c])
1120 [60 61 62 %a %b %c ~]
1121 [@ud @ud @ud %a %b %c %~]
1122 ~zod/arvo=/hoon/hoon> (welp [sa+1 so+2 ~] si/3)
1123 [[%sa 1] [%so 2] %si 3]
1132Turns a `++list` of lists into a single list by promoting the elements of
1133each sublist into the higher.
1154 (welp +<- $(+< +<+))
1162 > (zing (limo [(limo ['a' 'b' 'c' ~]) (limo ['e' 'f' 'g' ~]) (limo ['h' 'i' 'j' ~]) ~]))
1163 ~['a' 'b' 'c' 'e' 'f' 'g' 'h' 'i' 'j']
1164 > (zing (limo [(limo [1 'a' 2 'b' ~]) (limo [3 'c' 4 'd' ~]) ~]))
1165 ~[1 97 2 98 3 99 4 100]
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list