cheddar-lang / Cheddar

🧀 Cheddar, the language that works for you
cheddar.vihan.org
Apache License 2.0
28 stars 9 forks source link

Right Functional Bonding Malfunction In Map #102

Open kckennylau opened 7 years ago

kckennylau commented 7 years ago

Desired Behavior

According to Functional Bonding · Cheddar Documentation, f & a is equivalent to *args -> f(*(args + [a])), meaning that (+)&1 is equivalent to a->(+)(a,1), which is equivalent to a->a+1.

How to Reproduce

print ([1,2,3].map((+)&1)) is expected to produce [2,3,4], but produced [1,3,5] instead.

vihanb commented 7 years ago

This is desired behavior. .map produces 3 args: (item, index, array) so it's really calling (+)(item, index, array, 1). You can use => e.g.: [1,2,3]=>((+)&1) or (+:1)