git.s-ol.nu alive / b342318
add merge! builtin op s-ol 6 months ago
1 changed file(s) with 26 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
498498 return if setup
499499 @out\set @inputs.sig!
500500
501 merge = Constant.meta
502 meta:
503 name: 'merge!'
504 summary: "Merge !-streams."
505 examples: { '(merge! evt1 evt2 [evt3…])' }
506 description: "
507 Reenters the innermost `(loop)` from the top, with `k1` bound to `nv1`, `k2`
508 bound to `nv2`…
509
510 `(recur nv1 [nv2…])` is equivalent to `(*recur* nv1 [nv2…])`."
511
512 value: class extends Op
513 val_or_evt = (sig! / evt!)!
514 pattern = val_or_evt\rep 2
515 setup: (inputs) =>
516 values = pattern\match inputs
517 super [Input.hot v for v in *values]
518 @out = @inputs[1]\type!\mk_evt!
519
520 tick: =>
521 for input in *@inputs
522 if input\dirty!
523 @out\set input!
524 return
525
501526 array = Constant.meta
502527 meta:
503528 name: 'array'
689714 '=': to_const
690715 '~': to_sig
691716 '!': to_evt
717 'merge!': merge
692718
693719 '->': thread_first
694720 '->>': thread_last