by bryanrasmussen · 6y ago · 0 comments
if? even? x -> print [x "is even"]
but I couldn't find it in Arithmetic, Comparison, Core, Logic, or Numbers - I figured those were the most obvious places to look.
I was wondering specifically if this example
loop 1..10 'x [ if? even? x -> print [x "is even"] else -> print [x "is odd"] ]
could be rewritten
loop 1..10 'x [ even? x -> print [x "is even"] odd? x -> print [x "is odd"] ]
and what other number checking things one could do - like decimal?, positive? negative?
Regarding the syntax:
every "function" in Arturo takes a specific number of arguments. in that case: loop, if?, even? else are ALL functions (there are no special constructs in Arturo, nor reserved keywords).
Regarding your second example/question: you could have written it like that, but it wouldn't do as you expect.
What can be done though is using the 'case function.
For any other questions, doubts, ideas or even code contribution, you're welcome to post anything at Github or via our Gitter community: https://gitter.im/arturo-lang/community or Discord: https://discord.gg/YdVK2CB
Let me know what you think! :)