Changeset 40184 in project


Ignore:
Timestamp:
06/13/21 10:00:48 (6 weeks ago)
Author:
Idiomdrottning
Message:

Descend and NIY

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/brev-separate

    r40176 r40184  
    487487
    488488
     489==== descend
     490Descend is sort of like a named {{let}} except it does three magic things.
     491
     492First of all, the let tag is always {{desc}}. I almost named the macro
     493itself {{desc}} but that would've been bad since then you couldn't nest
     494them.
     495
     496Second of all, if the binding is to a value of the same name e.g.
     497{{(lis lis)}} you can just put the name there. You can mix these
     498shorthand bindings with normal bindings.
     499
     500Now, if the first binding starts of as {{empty?}}, the third magic thing
     501(which I'll get into shortly) is disabled and you can go on your merry
     502way only using the above two magics.
     503
     504 (descend ((sum 0) (nums '(1 2 3 4)))
     505          (if (null? nums) sum
     506              (desc (+ sum (car nums)) (cdr nums))))
     507
     508⇒ 10
     509
     510Otherwise, if it does start out non-empty...
     511
     512 (descend ((nums '(1 2 3 4)))
     513          (+ (car nums) (desc (cdr nums))))
     514
     515⇒ 10
     516
     517That's right. It only recurs the value is non-empty.
     518
     519
    489520=== Doing stuff
    490521
     
    500531
    501532
     533==== niy
     534 (niy)
     535
     536NIY stands for "not implemented yet".
     537
     538Errors out if called with no arguments or if any of its arguments are true.
     539Sort of like a living FIXME.
     540
     541
    502542=== Source code
    503543 git clone https://idiomdrottning.org/brev-separate
Note: See TracChangeset for help on using the changeset viewer.