Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I agree that functional programming is wonderful, but imperative programs can often look especially clear. Quite a conundrum.

In Fexl (http://fexl.com), you can reduce the nesting by using the ';' ("pivot") syntax. So instead of this:

  print (fold add 0 (map int (filter valid_int (split "+" exp)))
You can eliminate the nesting as follows:

  print; fold add 0; map int; filter valid_int; split "+" exp
You could simplify that form by redefining "int" to return 0 on any invalid input. So we redefine int as follows:

  \int=(\str valid_int str (int str) 0)
Presumably the original int dies on invalid input. Actually I would prefer that the inner int function returns either no or (yes val), i.e. a "maybe", and then we could wrap the default 0 around that. But in any case we now have a robust, fault-tolerant int function, and we can now say:

  print; fold add 0; map int; split "+" exp


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: