Interesting way to write function

About advanced scenes, and the Thyme scripting language used in Algodoo.

Interesting way to write function

Postby Kilinich » Thu May 10, 2012 9:56 am

scene.my.max := (a,b) => {[a, b](math.toInt(a > b))}
or
scene.my.max := (a,b,c) => {[a, b, c](a > b && a > c ? 0 : {b > a && b > c ? 1 : 2})}

It's not very useful in examples but you gon the point: [array](index)
Can became handy in complex "if - case" with many variants and multiple usage of one.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Interesting way to write function

Postby tatt61880 » Thu May 10, 2012 5:51 pm

I don't think this notation is not good to understand, but is interesting. :lol:

["a",["b",["c", "d"]],"e"] 1 1 0 returns "c". ;)
(NOTE: I don't recommend to reducing (). )
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 4 guests