Comments, JSON refactoring, ++flit $+(_,? $+(* (unit)))

This commit is contained in:
Anton Dyudin 2014-10-29 13:59:01 -07:00 committed by Anton Dyudin
parent a0786715a5
commit 13f71f1e46
3 changed files with 19 additions and 34 deletions

View File

@ -619,6 +619,11 @@
|* [a=(unit) b=*]
?~(a b u.a)
::
++ flit :: make filter
|* a=_,?
|* b=*
?.((a b) ~ [~ u=b])
::
++ lift :: lift gate (fmap)
|* a=gate :: flipped
|* b=(unit) :: curried
@ -2142,11 +2147,11 @@
=+ f=$(a r.a, b -.e)
[-.f [n.a +.e +.f]]
::
+- run :: turns to tuples
+- run :: apply gate to values
|* b=_,*
|-
?~ a a
[[p.n.a (b q.n.a)] $(a l.a) $(a r.a)]
[n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)]
::
+- tap :: listify pairs
~/ %tap
@ -2176,7 +2181,7 @@
$(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a)
$(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a)
::
+- urn :: turn
+- urn :: apply gate to nodes
|* b=$+([* *] *)
|-
?~ a ~
@ -2899,8 +2904,7 @@
::
++ sand :: atom sanity
|= a=@ta
|= b=@ ^- (unit ,@)
?.(((sane a) b) ~ [~ b])
(flit (sane a))
::
++ sane :: atom sanity
|= a=@ta

View File

@ -652,8 +652,7 @@
(bind (stud (trip p.jon)) |=(a=date (year a)))
::
++ di :: millisecond date
|= jon=json
%+ bind (ni jon)
%- cu :_ ni
|= a=@u ^- @da
(add ~1970.1.1 (div (mul ~s1 a) 1.000))
::
@ -705,10 +704,7 @@
|* wit=fist
|= jon=json
?. ?=([%o *] jon) ~
%- zm
|-
?~ p.jon ~
[n=[p=p.n.p.jon q=(wit q.n.p.jon)] l=$(p.jon l.p.jon) r=$(p.jon r.p.jon)]
(zm (~(run by p.jon) wit))
::
++ pe :: prefix
|* [pre=* wit=fist]
@ -752,46 +748,30 @@
u:->.but
[u:->.but (zp +.but)]
::
++ zt :: unit tuple
|* lut=(list (unit))
?: =(~ lut) ~
?. |- ^- ?
?~(lut & ?~(i.lut | $(lut t.lut)))
~
%- some
|-
?~ lut !!
?~ t.lut u:+.i.lut
[u:+.i.lut $(lut t.lut)]
::
++ zm :: collapse unit map
|* lum=(map term (unit))
?. |- ^- ?
?~(lum & ?~(q.n.lum | &($(lum l.lum) $(lum r.lum))))
?: (~(rep by lum) | |=([[@ a=(unit)] b=?] |(b ?=(~ a))))
~
%- some
|-
?~ lum ~
[[p.n.lum u:+.q.n.lum] $(lum l.lum) $(lum r.lum)]
(some (~(run by lum) need))
--
::
++ joba
++ joba :: object from k-v pair
|= [p=@t q=json]
^- json
[%o [[p q] ~ ~]]
::
++ jobe
++ jobe :: object from k-v list
|= a=(list ,[p=@t q=json])
^- json
[%o (~(gas by *(map ,@t json)) a)]
::
++ jape
++ jape :: string from tape
|= a=tape
^- json
[%s (crip a)]
::
++ jone
|= a=@
++ jone :: number from unsigned
|= a=@u
^- json
:- %n
?: =(0 a) '0'

View File

@ -7,6 +7,7 @@
++ grab :: convert from
|%
++ noun ,@t :: clam from %noun
++ json (cork so:jo need)
--
++ grow
|%