Skip to content
Discussion options

You must be logged in to vote

Repetitions only work in a “flat” manner, not in a “nested” manner as in your example. Similar to Racket, the way to achieve nesting is through recursion, so there are a couple of approaches here:

  1. Explicit recursion with recur, like
expr.macro 'curry ($arg, ...) ... ~nonempty: $body':
  recur loop(argss = ['($arg, ...)', ...]):
    match argss
    | [args, more, ...]:
        'fun $args: $(loop([more, ...]))'
    | []:
        body
  1. Expand to self, like
expr.macro 'curry ($arg, ...) ... ~nonempty: $body':
  match ['($arg, ...)', ...]
  | [args]:
      'fun $args: $body'
  | [args, more, ...]:
      'fun $args: curry $more ...: $body'
  1. Something like Racket for/foldr, which is current…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Forthoney
Comment options

@Forthoney
Comment options

@usaoc
Comment options

usaoc Nov 13, 2025
Collaborator

Answer selected by Forthoney
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants