Any of array's variables?
6 posts • Page 1 of 1
Any of array's variables?
I want to make a function, to read if anything of the integers of an array are true/false/etc..
I have tried:
_Array=[fase,false,false,true,false];
scene.my.AnyOf= (array, variable)=>{
for(string.length(array),(i)=>{array(i)==variabe})?"there's something equal":"there isn't anything equal"
}
scene.my.AnyOf(_Array,true);
But it does not work, it gives me an error.
Thanks.
I have tried:
_Array=[fase,false,false,true,false];
scene.my.AnyOf= (array, variable)=>{
for(string.length(array),(i)=>{array(i)==variabe})?"there's something equal":"there isn't anything equal"
}
scene.my.AnyOf(_Array,true);
But it does not work, it gives me an error.
Thanks.
- lololoer16_17
- Posts: 18
- Joined: Tue Jan 21, 2014 8:55 pm
- Location: Spain (South)
Re: Any of array's variables?
That's easy!
Define your array in the console: scene.my.array := {[true,true,false,false,true,true]}
Test each array element for true or false: scene.my.array(n) ? {Do this if true}:{Do this if false}
where, n is the array element beginning with 0 (zero).
Is this what you needed?
Define your array in the console: scene.my.array := {[true,true,false,false,true,true]}
Test each array element for true or false: scene.my.array(n) ? {Do this if true}:{Do this if false}
where, n is the array element beginning with 0 (zero).
Is this what you needed?
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Any of array's variables?
No, Xray, I mean:
array= [false,true,false,false,true,true];
is there anything true on the array list?{do something}:{do something};
I don't mean to ask for an specific element, I want to ask if there's any element true on the array.
array= [false,true,false,false,true,true];
is there anything true on the array list?{do something}:{do something};
I don't mean to ask for an specific element, I want to ask if there's any element true on the array.
- lololoer16_17
- Posts: 18
- Joined: Tue Jan 21, 2014 8:55 pm
- Location: Spain (South)
Re: Any of array's variables?
- Code: Select all
Scene.my.xFor := (n1, n2, code)=>{
n2 > n1 ? {
m := (n1 + n2) / 2;
scene.my.xFor(n1, m, code);
scene.my.xFor(m + 1, n2, code)
} : {code(n1)}
};
scene.my.isAnyTrue = (ra)=>{
v = false;
n = string.length(ra) - 1;
Scene.my.xFor(0, n, (i)=>{
ra(i) ? {v = true} : {}
});
v
}
scene.my.ra = [false,false,true,false];
scene.my.isAnyTrue(scene.my.ra);
scene.my.ra = [false,false,false,false];
scene.my.isAnyTrue(scene.my.ra);
scene.my.xFor is from Kilinich and has no limit to the number of iterations.
- s_noonan
- Posts: 61
- Joined: Tue Mar 30, 2010 2:25 am
Re: Any of array's variables?
Thanks s_noonan

- lololoer16_17
- Posts: 18
- Joined: Tue Jan 21, 2014 8:55 pm
- Location: Spain (South)
Re: Any of array's variables?
He's GOOD! 
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
6 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests



