(defun (Isprime, ([x])),
((for ([x]), (0), ((sqr ([y]))),
((if (mod (x), (y)), (0)),
(ifeq (Exit (2)))),
(print ([x] Is prime)))
The if is similar to a cmp in asm. It basically sets flags for things like ifeq, ifneq, ect. to use. Exit (2) basically means, (move 2 brackets up), which moves it up out of the piece of code that we have, and further along). See how elegant this is?
pubic function isprime(x as integer)
for x = 0 to sqr(y) step 1
if x % y = 0 then
exit function
end if
next for
print x & " is prime"
end function
The lispish code (Ascript), just seems elegant. (and i only came up with the language idea a few days ago!). Also Ascript would be very easy to add oo features to. (because everything is the same. Objects would have to be a little different. And that wouldn't be too good...) So now, if you wanted to print of the arguments of a function, you would have your function (Set ([myfunc]), ( (while (not (emptylist (Args))), ( (print (pop (args)))) Which seems very elegant to me. You can also get individual elements from the args list, by simply going (Set ([x]), (element (args), (2))) ect. Which would lend itself to a nice little macro for setting up arguments as you like them. For eg. (Doargs (args), ([x], [y], [z], [theta])) Which would just be too simple to be considered a challange! What do you think of this? From, Nice coder [Edited by - Nice Coder on March 24, 2005 4:50:40 PM]