@@ -1,815 +0,0 @@
9−A- more or less low priority and/or currently in the wrong section
12−------------------------------------------------------------------------
14−------------------------------------------------------------------------
20−Inverts a list of changes `bur`. Skips stay constant and replaces are
21−swapped. Produces a `bur`.
26−`bur` is a [`++urge`]().
31−The `++urge` of a noun.
36− ++ berk :: invert diff patch
43− | [%| q.i.bur p.i.bur]
50− ~zod/try=> (berk `(urge)`~[`10 %|^[~[2] ~[3 4]] `5])
51− ~[[%.y p=10] [%.n p=~[3 4] q=~[2]] [%.y p=5]]
52− ~zod/try=> (lurk "somes" `(urge char)`~[`1 [%| "o" "a"] `3])
54− ~zod/try=> (berk `(urge char)`~[`1 [%| "o" "a"] `3])
55− ~[[%.y p=1] [%.n p="a" q="o"] [%.y p=3]]
56− ~zod/try=> (lurk "sames" (berk `(urge char)`~[`1 [%| "o" "a"] `3]))
59−------------------------------------------------------------------------
65−Produces a patch between two nouns, by change type
70−`pum` is an [`++umph`]().
80− ++ diff :: generate patch
82− |= [old=* new=*] ^- udon
84− ?+ pum ~|(%unsupported !!)
85− %a [%d (nude old new)]
86− %b =+ [hel=(cue ((hard ,@) old)) hev=(cue ((hard ,@) new))]
88− %c =+ [hel=(lore ((hard ,@) old)) hev=(lore ((hard ,@) new))]
89− [%c (lusk hel hev (loss hel hev))]
96− ~zod/try=> ((diff %a) 20 21)
97− [p=%a q=[%d p=[%1 p=21] q=[%1 p=20]]]
98− ~zod/try=> ((diff %a) [1 2 3] [1 2 4])
102− p=[p=[%0 p=2] q=[p=[%0 p=6] q=[%1 p=4]]]
103− q=[p=[%0 p=2] q=[p=[%0 p=6] q=[%1 p=3]]]
110− ~zod/try=> ((diff %b) 0v4hh 0vph)
111− [p=%b q=[%d p=[p=[%0 p=2] q=[%0 p=2]] q=[p=[%0 p=3] q=[%1 p=2]]]]
112− ~zod/try=> ((diff %c) (role 'sam' 'les' 'les' 'kor' ~) (role 'sam' 'mor' 'kor' ~))
113− [p=%c q=[%c p=~[[%.y p=1] [%.n p=~[7.562.604 7.562.604] q=~[7.499.629]] [%.y p=1]]]]
114− ~[[%.y p=0] [%.y p=0] [%.y p=1] [%.n p=<|les les|> q=<|mor|>] [%.y p=1]]
115− ~zod/try=> (,[%c %c (urge cord)] ((diff %c) (role 'sam' 'les' 'les' 'kor' ~) (role 'sam' 'mor' 'kor' ~)))
116− [%c %c ~[[%.y p=1] [%.n p=<|les les|> q=<|mor|>] [%.y p=1]]]
118−------------------------------------------------------------------------
124−Finds a subsequence of repeated elements within two [`++list`]()s, using
125−several internal helper arms. Produces a [`++tape`]().
130−`hel` is a [`++list`]() of [nouns]().
132−`hev` is a [++list`]() of nouns.
139−A [++list`]() of nouns.
144− ++ loss :: longest subsequence
146− |* [hel=(list) hev=(list)]
149− =+ [inx=0 sev=*(map ,@t (list ,@ud))]
152− =+ guy=(~(get by sev) i.hev)
153− $(hev t.hev, inx +(inx), sev (~(put by sev) i.hev [inx ?~(guy ~ u.guy)]))
154− =| gox=[p=@ud q=(map ,@ud ,[p=@ud q=_hev])]
158− ++ abet =.(q.rag ?:(=([& 0] p.rag) q.rag [p.rag q.rag]) (flop q.rag))
159− ++ hink :: extend fits top
160− |= [inx=@ud goy=@ud] ^- ?
161− |(=(p.gox inx) (lth goy p:(need (~(get by q.gox) inx))))
163− ++ lonk :: extend fits bottom
164− |= [inx=@ud goy=@ud] ^- ?
165− |(=(0 inx) (gth goy p:(need (~(get by q.gox) (dec inx)))))
168− |= [inx=@ud goy=@ud]
172− :- ?:(=(inx p.gox) +(p.gox) p.gox)
173− %+ ~(put by q.gox) inx
174− [goy (snag goy hev) ?:(=(0 inx) ~ q:(need (~(get by q.gox) (dec inx))))]
177− ++ merg :: merge all matches
181− =+ [inx=0 zes=*(list ,[p=@ud q=@ud])]
183− ?: |(?=(~ gay) (gth inx p.gox)) zes
184− ?. (lonk inx i.gay) $(gay t.gay)
185− ?. (hink inx i.gay) $(inx +(inx))
186− $(inx +(inx), gay t.gay, zes [[inx i.gay] zes])
188− ?~(zes +>.^$ $(zes t.zes, +>.^$ (lune i.zes)))
195− $(hev t.hev, rag (done %| ~ [i.hev ~]))
197− $(hel t.hel, rag (done %| [i.hel ~] ~))
199− +(rag (done %| (flop hel) (flop hev)))
202− $(lcs t.lcs, hel t.hel, hev t.hev, rag (done %& 1))
203− $(hev t.hev, rag (done %| ~ [i.hev ~]))
205− $(hel t.hel, rag (done %| [i.hel ~] ~))
206− $(hel t.hel, hev t.hev, rag (done %| [i.hel ~] [i.hev ~]))
212− ~zod/try=> (loss "sam" "sem")
214− ~zod/try=> (loss "samo" "semo")
216− ~zod/try=> (loss "sakmo" "semo")
218− ~zod/try=> (loss "ferdinham" "ferdilapos
219− ~ <syntax error at [1 30]>
220− ~zod/try=> (loss "ferdinham" "ferdilapos")
223−------------------------------------------------------------------------
229−Finds a subsequence of repeated elements within two
230−[`++list`](/docs/hoon/library/1#++list)s, producing a [\`++tape]().
235−A cell of two `++tape`s, `hel` and `hev`.
245− ++ locz :: trivial algorithm
246− |= [hel=tape hev=tape]
248− =+ [leh=(lent hel) veh=(lent hev)]
251− |- ^- [p=@ud q=tape]
253− ?: |(=(0 leh) =(0 veh)) [0 ~]
254− =+ [dis=(snag (dec leh) hel) dat=(snag (dec veh) hev)]
256− =+ say=$(leh (dec leh), veh (dec veh))
257− [+(p.say) [dis q.say]]
258− =+ [lef=$(leh (dec leh)) rig=$(veh (dec veh))]
259− ?:((gth p.lef p.rig) lef rig)
265− ~zod/try=> (locz "samukot" "semelkot")
267− ~zod/try=> (locz "samukot" "samelkot")
270−------------------------------------------------------------------------
276−Split on newlines, ascii `10`
288−A `++list` of atoms of odor [`@t`]() ([`++cord`]()).
292− ++ lore :: atom to line list
297− ?: =(0 lub) (flop tez)
301− =+ gam=(cut 3 [meg 1] lub)
302− ?:(|(=(10 gam) =(0 gam)) meg $(meg +(meg)))
303− =+ res=(rsh 3 +(meg) lub)
304− ?: &(=(0 (cut 3 [meg 1] lub)) !=(0 res))
306− $(lub res, tez [(end 3 meg lub) tez])
312− ~zod/try=> (lore 'soke\0alas\0amep')
314− ~zod/try=> (lore '|= a=@\0a=+ b=(add a 5)\0a(mix b a)')
315− <||= a=@ =+ b=(add a 5) (mix b a)|>
316− ~zod/try=> `wain`[(fil 3 80 ' ') (lore '|= a=@\0a=+ b=(add a 5)\0a(mix b a)')]
323−------------------------------------------------------------------------
329−Join line list with newlines.
334−A `++list` of atoms of [odor]() [`@t`]() ([`++cord`]()).
341−An atom of [odor]() [`@t`]() ([`++cord`]().
346− ++ role :: line list to atom
348− (rap 3 (turn tez |=(a=@t (cat 3 a 10))))
354− ~zod/try=> (role 'sep' 'tek' 'lap' ~)
355− 3.230.709.852.558.292.782.985.274.739
356− ~zod/try=> `@t`(role 'sep' 'tek' 'lap' ~)
363−------------------------------------------------------------------------
369−Use [`++udon`]() to change [noun]().
374−A cell of an `++udon`, `don`, and a noun, `src`.
384− ++ lump :: apply patch
387− ?+ p.don ~|(%unsupported !!)
389− ?+ -.q.don ~|(%unsupported !!)
391− %c (lurk ((hard (list)) src) p.q.don)
392− %d (lure src p.q.don)
396− =+ dst=(lore ((hard ,@) src))
398− ?+ -.q.don ~|(%unsupported !!)
399− %a ((hard (list ,@t)) q.q.don)
400− %c (lurk dst p.q.don)
408− ~zod/try=> (lump [%a %a 20 25] 20)
410− ~zod/try=> (lump [%a %d [[%0 1] [%0 1]] [%0 2]] 20)
412− ~zod/try=> (lump [%c %a ~['sa' 'le'] ~['sa' 'lo']] 'sa\0ale')
414− ~zod/try=> (,@t (lump [%c %a ~['sa' 'le'] ~['sa' 'lo']] 'sa\0ale'))
419− ~zod/try=> (,@t (lump [%c %c `1 [%| ~['le'] ~['lo' 'ma']] ~] 'sa\0ale'))
426−------------------------------------------------------------------------
432−Patch a by references to axis and literal.
437−A cell of a [noun](), `a`, and an [`++upas`](), `b`.
447− ++ lure :: apply tree diff
452− ?+ -.b ~|(%unsupported !!)
460− ~zod/try=> (lure ~[1 2] [[%0 2] [%1 3] [%0 7]])
462− ~zod/try=> (lure ~[1 2 4] [[%0 2] [%1 3] [%0 7]])
465−------------------------------------------------------------------------
471−Reverse a patch (preprocessor unchanged)
476−`don` is an [`++udon`]().
486− ++ limp :: invert patch
489− ?+ -.q.don ~|(%unsupported !!)
490− %a [%a q.q.don p.q.don]
491− %c [%c (berk p.q.don)]
492− %d [%d q.q.don p.q.don]
499− ~zod/try=> (limp [%a %a 20 40])
500− [p=%a q=[%a p=40 q=20]]
501− ~zod/try=> (limp [%c %c ~[`20 [%| ~[52 53] ~[51]] `6]])
502− [p=%c q=[%c p=~[[%.y p=20] [%.n p=~[51] q=~[52 53]] [%.y p=6]]]]
503− ~zod/try=> (limp [%a %d [[%0 1] [%0 1]] [%0 2]])
504− [p=%a q=[%d p=[%0 p=2] q=[p=[%0 p=1] q=[%0 p=1]]]]
506−------------------------------------------------------------------------
512−Prep atom for diff: leave alone, cue, or split by newlines.
517−A cell of an [`++umph`](), `pum`, and a [noun](), `src`.
527− ++ hump :: general prepatch
528− |= [pum=umph src=*] ^- *
529− ?+ pum ~|(%unsupported !!)
531− %b (cue ((hard ,@) src))
532− %c (lore ((hard ,@) src))
539− ~zod/try=> (hump %a ~)
541− ~zod/try=> (hump %a 40)
543− ~zod/try=> (hump %c 40)
545− ~zod/try=> (hump %c 'as')
547− ~zod/try=> (hump %c 'as\0alok')
548− [29.537 7.040.876 0]
549− ~zod/try=> (hump %b 0vph)
552−------------------------------------------------------------------------
558−Re-atomize after diff: leave alone, jam, or join with newlines.
563−A cell of an [`++umph`](), `pum`, and a [noun](), `dst`.
573− ++ husk :: unprepatch
574− |= [pum=umph dst=*] ^- *
575− ?+ pum ~|(%unsupported !!)
578− %c (role ((hard (list ,@)) dst))
585− ~zod/try=> (husk %a 0)
587− ~zod/try=> (husk %a 40)
589− ~zod/try=> (husk %c [40 0])
591− ~zod/try=> (rip 3 (,@ (husk %c [40 0])))
593− ~zod/try=> (husk %c [%as 0])
595− ~zod/try=> (husk %c [%as 0])
597− ~zod/try=> (,@t (husk %c [%as 0]))
601− ~zod/try=> (husk %c [%as %lok 0])
602− 2.932.876.065.272.673
603− ~zod/try=> (,@t (husk %c [%as %lok 0]))
608− ~zod/try=> (husk %b [1 1])
610− ~zod/try=> (,@uv (husk %b [1 1]))
615−------------------------------------------------------------------------
621−Amend list using an urge: [`++list`]() of `[%& {number skipped}]` and
628−A cell of a `++list` of [noun]()s, `hel`, and an [`++urge`]() of a noun, `rug`.
638− ++ lurk :: apply list patch
639− |* [hel=(list) rug=(urge)]
648− hel (slag p.i.rug hel)
649− war (weld (flop (scag p.i.rug hel)) war)
655− hel =+ gur=(flop p.i.rug)
658− ?>(&(?=(^ hel) =(i.gur i.hel)) $(hel t.hel, gur t.gur))
659− war (weld q.i.rug war)
667− ~zod/try=> (lurk "hema" `(urge char)`~[`1 [%| "e" "ru"] `2])
669− ~zod/try=> (lurk "koltep" `(urge char)`~[`3 [%| "et" ""] `1])
672−------------------------------------------------------------------------
678−Using a common sequence, generate urge from two [`++list`]()s.
684−A cell of three `++list`s of [noun](), `hel`, `hev`, and `lcs`.
692− ++ lusk :: lcs to list patch
693− |* [hel=(list) hev=(list) lcs=(list)]
699− => .(rag [p=rag q=*(list ,_rag)])
702− ++ abet =.(q.rag ?:(=([& 0] p.rag) q.rag [p.rag q.rag]) (flop q.rag))
708− | [[%| (weld p.new p.p.rag) (weld q.new q.p.rag)] q.rag]
709− & [new [p.rag q.rag]]
712− | [new ?:(=(0 p.p.rag) q.rag [p.rag q.rag])]
713− & [[%& (add p.p.rag p.new)] q.rag]
722− $(hev t.hev, rag (done %| ~ [i.hev ~]))
724− $(hel t.hel, rag (done %| [i.hel ~] ~))
726− +(rag (done %| (flop hel) (flop hev)))
729− $(lcs t.lcs, hel t.hel, hev t.hev, rag (done %& 1))
730− $(hev t.hev, rag (done %| ~ [i.hev ~]))
732− $(hel t.hel, rag (done %| [i.hel ~] ~))
733− $(hel t.hel, hev t.hev, rag (done %| [i.hel ~] [i.hev ~]))
739− ~zod/try=> (lusk "hamok" "hasok" "haok")
740− ~[[%.y p=2] [%.n p="m" q="s"] [%.y p=2]]
741− ~zod/try=> (lusk "hamok" "hasok" "hak")
742− ~[[%.y p=2] [%.n p="om" q="os"] [%.y p=1]]
743− ~zod/try=> (lusk "telroga" "tesomga" "teoga")
744− ~[[%.y p=2] [%.n p="rl" q="s"] [%.y p=1] [%.n p="" q="m"] [%.y p=2]]
745− ~zod/try=> (lurk "telroga" `(urge char)`~[[%.y p=2] [%.n p="rl" q="s"] [%.y p=1] [%.n p="" q="m"] [%.y p=2]])
748−------------------------------------------------------------------------
754−Generate tree diff from two nouns.
759−A cell of two nouns, `a` and `b`.
764−A cell of two [`++upas`](), `p` and `q`.
769− ++ nude :: tree change
772− =< [p=(tred a b) q=(tred b a)]
774− ++ axes :: locs of nouns
775− |= [a=@ b=*] ^- (map ,* axis)
778− => .(c (~(put by c) b a))
782− %- ~(uni by $(a (mul 2 a), b -.b))
783− $(a +((mul 2 a)), b +.b)
785− ++ tred :: diff a->b
786− |= [a=* b=*] ^- upas
790− => .(c (~(get by d) b))
794− =+ e=^-(upas [$(b -.b) $(b +.b)])
796− [[%1 *] [%1 *]] [%1 [p.p.e p.q.e]]
805− ~zod/try=> (nude 40 20)
806− [p=[%1 p=20] q=[%1 p=40]]
807− ~zod/try=> (nude [5 5] 5)
808− [p=[%0 p=3] q=[p=[%0 p=1] q=[%0 p=1]]]
809− ~zod/try=> (nude "sam" "sal")
810− [ p=[p=[%1 p=115] q=[p=[%1 p=97] q=[p=[%1 p=108] q=[%0 p=15]]]]
811− q=[p=[%1 p=115] q=[p=[%1 p=97] q=[p=[%1 p=109] q=[%0 p=15]]]]
814−------------------------------------------------------------------------