Commented set, map, jar, jug, queue arms. Added jet tag to ++ fac

This commit is contained in:
John Dulin 2014-06-01 18:31:32 -07:00
parent 9b523d1767
commit c037d463cc

View File

@ -480,7 +480,8 @@
$(a (sub a b), c +(c)) $(a (sub a b), c +(c))
:: ::
++ fac :: factorial ++ fac :: factorial
|= a=@ :: This should be jetted. ~/ %fac
|= a=@
^- @ ^- @
?: =(0 a) ?: =(0 a)
1 1
@ -1323,7 +1324,7 @@
++ in :: set engine ++ in :: set engine
~/ %in ~/ %in
|/ a=(set) |/ a=(set)
+- all +- all :: logical AND
~/ %all ~/ %all
|* b=$+(* ?) |* b=$+(* ?)
|- ^- ? |- ^- ?
@ -1331,7 +1332,7 @@
& &
?&((b n.a) $(a l.a) $(a r.a)) ?&((b n.a) $(a l.a) $(a r.a))
:: ::
+- any +- any :: logical OR
~/ %any ~/ %any
|* b=$+(* ?) |* b=$+(* ?)
|- ^- ? |- ^- ?
@ -1339,7 +1340,7 @@
| |
?|((b n.a) $(a l.a) $(a r.a)) ?|((b n.a) $(a l.a) $(a r.a))
:: ::
+- del +- del :: b without any a
~/ %del ~/ %del
|* b=* |* b=*
|- ^+ a |- ^+ a
@ -1356,7 +1357,7 @@
[n.l.a l.l.a $(l.a r.l.a)] [n.l.a l.l.a $(l.a r.l.a)]
[n.r.a $(r.a l.r.a) r.r.a] [n.r.a $(r.a l.r.a) r.r.a]
:: ::
+- dig +- dig :: axis of a in b
|= b=* |= b=*
=+ c=1 =+ c=1
|- ^- (unit ,@) |- ^- (unit ,@)
@ -1366,7 +1367,7 @@
$(a l.a, c (peg c 6)) $(a l.a, c (peg c 6))
$(a r.a, c (peg c 7)) $(a r.a, c (peg c 7))
:: ::
+- gas +- gas :: concatenate
~/ %gas ~/ %gas
|= b=(list ,_?>(?=(^ a) n.a)) |= b=(list ,_?>(?=(^ a) n.a))
|- ^+ a |- ^+ a
@ -1374,7 +1375,7 @@
a a
$(b t.b, a (put(+< a) i.b)) $(b t.b, a (put(+< a) i.b))
:: ::
+- has +- has :: b exists in a check
~/ %has ~/ %has
|* b=* |* b=*
|- ^- ? |- ^- ?
@ -1386,7 +1387,7 @@
$(a l.a) $(a l.a)
$(a r.a) $(a r.a)
:: ::
+- put +- put :: puts b in a, sorted
~/ %put ~/ %put
|* b=* |* b=*
|- ^+ a |- ^+ a
@ -1406,13 +1407,13 @@
[n.a l.a c] [n.a l.a c]
[n.c [n.a l.a l.c] r.c] [n.c [n.a l.a l.c] r.c]
:: ::
+- rep +- rep :: replace by tile
|* [b=* c=_,*] |* [b=* c=_,*]
|- |-
?~ a b ?~ a b
$(a r.a, b $(a l.a, b (c n.a b))) $(a r.a, b $(a l.a, b (c n.a b)))
:: ::
+- tap +- tap :: list tiles a set
~/ %tap ~/ %tap
|= b=(list ,_?>(?=(^ a) n.a)) |= b=(list ,_?>(?=(^ a) n.a))
^+ b ^+ b
@ -1420,7 +1421,7 @@
b b
$(a r.a, b [n.a $(a l.a)]) $(a r.a, b [n.a $(a l.a)])
:: ::
+- wyt +- wyt :: depth of set
.+ .+
|- ^- @ |- ^- @
?~(a 0 +((add $(a l.a) $(a r.a)))) ?~(a 0 +((add $(a l.a) $(a r.a))))
@ -1438,12 +1439,12 @@
:: ::
++ ja :: jar engine ++ ja :: jar engine
|/ a=(jar) |/ a=(jar)
+- get +- get :: gets list by key
|* b=* |* b=*
=+ c=(~(get by a) b) =+ c=(~(get by a) b)
?~(c ~ u.c) ?~(c ~ u.c)
:: ::
+- add +- add :: adds key-list pair
|* [b=* c=*] |* [b=* c=*]
=+ d=(get(a +>) b) =+ d=(get(a +>) b)
(~(put by a) [d c]) (~(put by a) [d c])
@ -1451,17 +1452,17 @@
:: ::
++ ju :: jug engine ++ ju :: jug engine
|/ a=(jug) |/ a=(jug)
+- get +- get :: gets set by key
|* b=* |* b=*
=+ c=(~(get by a) b) =+ c=(~(get by a) b)
?~(c ~ u.c) ?~(c ~ u.c)
:: ::
+- has +- has :: existence check
|* [b=* c=*] |* [b=* c=*]
^- ? ^- ?
(~(has in (get(+< a) b)) c) (~(has in (get(+< a) b)) c)
:: ::
+- put +- put :: adds key-set pair
|* [b=* c=*] |* [b=* c=*]
^+ a ^+ a
=+ d=(get(+< a) b) =+ d=(get(+< a) b)
@ -1471,7 +1472,7 @@
++ by :: map engine ++ by :: map engine
~/ %by ~/ %by
|/ a=(map) |/ a=(map)
+- all +- all :: logical AND
~/ %all ~/ %all
|* b=$+(* ?) |* b=$+(* ?)
|- ^- ? |- ^- ?
@ -1479,7 +1480,7 @@
& &
?&((b q.n.a) $(a l.a) $(a r.a)) ?&((b q.n.a) $(a l.a) $(a r.a))
:: ::
+- any +- any :: logical OR
~/ %any ~/ %any
|* b=$+(* ?) |* b=$+(* ?)
|- ^- ? |- ^- ?
@ -1487,7 +1488,7 @@
| |
?|((b q.n.a) $(a l.a) $(a r.a)) ?|((b q.n.a) $(a l.a) $(a r.a))
:: ::
+- del +- del :: delete at key b
~/ %del ~/ %del
|* b=* |* b=*
|- ^+ a |- ^+ a
@ -1504,7 +1505,7 @@
[n.l.a l.l.a $(l.a r.l.a)] [n.l.a l.l.a $(l.a r.l.a)]
[n.r.a $(r.a l.r.a) r.r.a] [n.r.a $(r.a l.r.a) r.r.a]
:: ::
+- dig +- dig :: axis of b key
|= b=* |= b=*
=+ c=1 =+ c=1
|- ^- (unit ,@) |- ^- (unit ,@)
@ -1514,7 +1515,7 @@
$(a l.a, c (peg c 6)) $(a l.a, c (peg c 6))
$(a r.a, c (peg c 7)) $(a r.a, c (peg c 7))
:: ::
+- gas +- gas :: concatenate
~/ %gas ~/ %gas
|* b=(list ,[p=* q=*]) |* b=(list ,[p=* q=*])
=> .(b `(list ,_?>(?=(^ a) n.a))`b) => .(b `(list ,_?>(?=(^ a) n.a))`b)
@ -1523,7 +1524,7 @@
a a
$(b t.b, a (put(+< a) p.i.b q.i.b)) $(b t.b, a (put(+< a) p.i.b q.i.b))
:: ::
+- get +- get :: grab value by key
~/ %get ~/ %get
|* b=* |* b=*
|- ^- ?(~ [~ u=_?>(?=(^ a) q.n.a)]) |- ^- ?(~ [~ u=_?>(?=(^ a) q.n.a)])
@ -1535,18 +1536,18 @@
$(a l.a) $(a l.a)
$(a r.a) $(a r.a)
:: ::
+- has +- has :: key existence check
~/ %has ~/ %has
|* b=* |* b=*
!=(~ (get(+< a) b)) !=(~ (get(+< a) b))
:: ::
+- mar +- mar :: add with validation
|* [b=_?>(?=(^ a) p.n.a) c=(unit ,_?>(?=(^ a) q.n.a))] |* [b=_?>(?=(^ a) p.n.a) c=(unit ,_?>(?=(^ a) q.n.a))]
?~ c ?~ c
(del b) (del b)
(put b u.c) (put b u.c)
:: ::
+- put +- put :: adds key-value pair
~/ %put ~/ %put
|* [b=* c=*] |* [b=* c=*]
|- ^+ a |- ^+ a
@ -1568,13 +1569,13 @@
[n.a l.a d] [n.a l.a d]
[n.d [n.a l.a l.d] r.d] [n.d [n.a l.a l.d] r.d]
:: ::
+- rep +- rep :: replace by product
|* [b=* c=_,*] |* [b=* c=_,*]
|- |-
?~ a b ?~ a b
$(a r.a, b $(a l.a, b (c n.a b))) $(a r.a, b $(a l.a, b (c n.a b)))
:: ::
+- rib +- rib :: transform + product
|* [b=* c=_,*] |* [b=* c=_,*]
|- ^+ [b a] |- ^+ [b a]
?~ a [b ~] ?~ a [b ~]
@ -1584,13 +1585,13 @@
=+ f=$(a r.a, b -.e) =+ f=$(a r.a, b -.e)
[-.f [n.a +.e +.f]] [-.f [n.a +.e +.f]]
:: ::
+- run +- run :: turns to tuples
|* b=_,* |* b=_,*
|- |-
?~ a a ?~ a a
[[p.n.a (b q.n.a)] $(a l.a) $(a r.a)] [[p.n.a (b q.n.a)] $(a l.a) $(a r.a)]
:: ::
+- tap +- tap :: listify pairs
~/ %tap ~/ %tap
|= b=(list ,_?>(?=(^ a) n.a)) |= b=(list ,_?>(?=(^ a) n.a))
^+ b ^+ b
@ -1598,7 +1599,7 @@
b b
$(a r.a, b [n.a $(a l.a)]) $(a r.a, b [n.a $(a l.a)])
:: ::
+- uni +- uni :: union, merge
~/ %uni ~/ %uni
|= b=_a |= b=_a
?@ b a ?@ b a
@ -1607,7 +1608,7 @@
b (~(uni by l.b) r.b) b (~(uni by l.b) r.b)
== ==
:: ::
+- wyt +- wyt :: depth of map
.+ .+
|- ^- @ |- ^- @
?~(a 0 +((add $(a l.a) $(a r.a)))) ?~(a 0 +((add $(a l.a) $(a r.a))))
@ -1626,17 +1627,17 @@
$(a [n.r.a $(a [n.a l.a l.r.a]) r.r.a]) $(a [n.r.a $(a [n.a l.a l.r.a]) r.r.a])
a a
:: ::
+- dep +- dep :: max depth of queue
|- ^- @ |- ^- @
?~ a 0 ?~ a 0
+((max $(a l.a) $(a r.a))) +((max $(a l.a) $(a r.a)))
:: ::
+- gas +- gas :: insert list to que
|= b=(list ,_?>(?=(^ a) n.a)) |= b=(list ,_?>(?=(^ a) n.a))
|- ^+ a |- ^+ a
?~(b a $(b t.b, a (put(+< a) i.b))) ?~(b a $(b t.b, a (put(+< a) i.b)))
:: ::
+- get +- get :: head-tail pair
|- ^+ [p=?>(?=(^ a) n.a) q=a] |- ^+ [p=?>(?=(^ a) n.a) q=a]
?~ a ?~ a
!! !!
@ -1648,27 +1649,27 @@
[n.a l.a q.b] [n.a l.a q.b]
[n.q.b [n.a l.a l.q.b] r.q.b] [n.q.b [n.a l.a l.q.b] r.q.b]
:: ::
+- nap +- nap :: removes head
?> ?=(^ a) ?> ?=(^ a)
?: =(~ l.a) r.a ?: =(~ l.a) r.a
=+ b=get(+< l.a) =+ b=get(+< l.a)
bal(+< ^+(a [p.b q.b r.a])) bal(+< ^+(a [p.b q.b r.a]))
:: ::
+- put +- put :: insert new head
|* b=* |* b=*
|- ^+ a |- ^+ a
?~ a ?~ a
[b ~ ~] [b ~ ~]
bal(+< a(l $(a l.a))) bal(+< a(l $(a l.a)))
:: ::
+- tap +- tap :: adds list to end
|= b=(list ,_?>(?=(^ a) n.a)) |= b=(list ,_?>(?=(^ a) n.a))
^+ b ^+ b
?~ a ?~ a
b b
$(a r.a, b [n.a $(a l.a)]) $(a r.a, b [n.a $(a l.a)])
:: ::
+- top +- top :: produces head
|- ^- (unit ,_?>(?=(^ a) n.a)) |- ^- (unit ,_?>(?=(^ a) n.a))
?~ a ~ ?~ a ~
?~(r.a [~ n.a] $(a r.a)) ?~(r.a [~ n.a] $(a r.a))