adam-mcdaniel / dune

A shell🐚 by the beach🏖️!
https://adam-mcdaniel.net/dune-website
MIT License
1.01k stars 20 forks source link

`fn@filter` doesn't work #78

Closed nivpgir closed 2 years ago

nivpgir commented 2 years ago

this looks like a very cool project! I tried out some stuff and found that:

 [1, 2, 3, 4, 5] | fn@filter ( x -> x == 1 )

prints: cannot add [] and item

while:

fn@filter ( x -> x == 1 ) [1, 2, 3, 4, 5] 

works as expected and returns [1]

not sure whats the cause of the difference but I managed to fix it by changing fn@filters implementation

to:

f -> list -> { let result = [];
  for item in list { if (f item) { let result = (+ result [item]) } else (None) }; result
}

I've been wanting a more functional shell for a long time and I hope dunesh could turn into this for me, so I'd love to see this fixed, let me know if you need any help 😄.

adam-mcdaniel commented 2 years ago

Addressed by this commit!