Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fixed-length list pattern #123

Merged

Conversation

nekketsuuu
Copy link
Contributor

@nekketsuuu nekketsuuu commented Nov 4, 2018

This PR implements fixed-length list pattern.

Example:

@require: standalone
@require: stdja

let show lst =
  let-rec aux
    | [] = ` `
    | [x] = x  % <-- This line!
    | (x :: xs) = x ^ `; `# ^ (aux xs)
  in `[` ^ (aux lst) ^ `]`
let-inline \show-string str = embed-string str

in
standalone '<
  +p {
    \show-string(show [`a`; `b`; `c`]);
  }
>

Without this, we must write a fixed-length list explicitly by cons and nil (e.g. x :: [] instead of [x]). In OCaml, we can use this kind of syntactic sugar.

@gfngfn gfngfn merged commit d3b03e1 into gfngfn:master Nov 5, 2018
@gfngfn
Copy link
Owner

gfngfn commented Nov 5, 2018

Thanks for the improvement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants