proglangbase / bbhw

Bye Bye Hello World
Mozilla Public License 2.0
4 stars 4 forks source link

Modified bbhw.erl to be less segmented. #18

Closed sthames42 closed 1 month ago

sthames42 commented 1 month ago

This version is much less segmented than the original but it is still not a single execution stream which I think is what you were asking for, @c4augustus. This new version supports all the ways to run this using escript, erl, or erl -noshell. To allow it only to run through escript means these two lines could be removed:

main(A) when is_atom(A)  -> main(atom_to_list(A));
main(F) when is_float(F) -> isBadNum(F), main();

main() without parameters simply reads the countdown: input from the console and calls main(_) with the result. The body of main() could be moved to line 27, thus keeping all the processing inside of main(_). We would still need main() -> main(""), however, and I like it this way better, anyway, because it clearly says "main with no parameters takes countdown input."

The lack of mutability and traditional looping statements makes it very challenging to do what you asked. While it may be possible with lambdas, I hardly think it's worth it and it seems counter to tacit Erlang development.

Anyway, take a look and let me know what you think.

sthames42 commented 1 month ago

I'm going to go ahead and merge this in to main. @c4augustus, take a look at both the Erlang and Elixir versions when you get a chance.