On Mon, Feb 14, 2011 at 11:35 PM, hard wyrd <[email protected]> wrote:
> Can your language do this?
>> eeny,meeny,miney,mo=1+1,1*2,1^10,1/1
>> print(eeny,meeny,miney,mo)
> 2 2 1 1
>> eeny,meeny,miney,mo=mo,meeny,miney,eeny
>> print(eeny,meeny,miney,mo)
> 1 2 1 2

ah, parallel assignments,

eeny,meeny,miney,mo=1+1,1*2,1^10,1/1

[eeny,meeny,miney,mo]
#=> [2, 2, 11, 1]

eeny,meeny,miney,mo=mo,meeny,miney,eeny

[eeny,meeny,miney,mo]
#=>[1, 2, 11, 2]


the diff is that in ruby, the "^" is an exclusive-or operator
eg,

0^0
#=> 0
0^1
#=> 1
1^0
#=> 1
1^1
#=> 0

for power notation, use "**", eg

2**8
#=> 256


now, try something like this,

x,*y,z=[1,3,5,9,2]

x
#=> 1
y
#=> [3, 5, 9]
z
#=> 2


best regards
-botp
_________________________________________________
Kagay-Anon Linux Users' Group (KLUG) Mailing List
[email protected] (http://lists.linux.org.ph/mailman/listinfo/klug)
Searchable Archives: http://archives.free.net.ph

Reply via email to