Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # version current
- # meh
- fold = macro data a b:
- accum = null
- each v in $ get data:
- if accum == null:
- accum = v
- else:
- accum = call a accum b v
- accum
- # version a
- # excess parameters are treated as names to block,
- # no need to adress them in macro definition
- # inconsistent with 'each', e.g. each a b in sometable:
- # would have to move names to the end to become consistent e.g. each sometable a b:
- fold = macro data cb:
- accum = null
- each v in data:
- if accum == null:
- accum = v
- else:
- accum = cb accum v
- accum
- # version b
- # more control, uglier macro definition
- fold = macro data a b cb:
- accum = null
- each v in (value data):
- if accum == null:
- accum = v
- else:
- # version b.0
- (name a) = accum
- (name b) = v
- accum = cb
- # version b.1
- accum = cb (bind a accum) (bind b v)
- # version b.2, would have to implement named parameters?
- accum = cb (a)=accum (b)=v
- accum
- # version c
- # fake type system
- fold = macro (value data) (name a) (name b) cb: # last parameter is always a block
- # ...
- # calling all of them
- fold sometable a b:
- a + b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement