So here's an idea for list comprehensions. I tried to stay in line with what I know from erlang and haskell. It compiles it all to for loops. I also added integer sequences, since I was getting tired of writing the generators by hand.
The basic syntax is: [<expr> | <generator> [, generator*[, guard* [, let_binding*]]]]
So things like this should compile:
[x | x ← [1..10]]
[(x, y, z) | x ← [1, 2, 3, 4, 5, 6], y ← [4..4], let z = 7, x > 2]
[f x | f ← [λarg → 3 * arg, λid → id], x ← [1, 2, 3]]
These should be the same (assuming you have the prelude with odd/even for the second one):
[odd * even | odd ← [1, 3, 5, 7, 9], even ← [2, 4, 6, 8, 10]]
[o * e | o ← [1..10], e ← [1..10], odd o, even e]
The types, however, usually show up as Native. So that's kind of an issue. There's probably more things that I forgot.
So here's an idea for list comprehensions. I tried to stay in line with what I know from erlang and haskell. It compiles it all to for loops. I also added integer sequences, since I was getting tired of writing the generators by hand.
The basic syntax is: [
<expr> | <generator> [, generator*[, guard* [, let_binding*]]]
]So things like this should compile:
These should be the same (assuming you have the prelude with odd/even for the second one):
The types, however, usually show up as
Native
. So that's kind of an issue. There's probably more things that I forgot.