SMath Studio Forum
»
SMath Studio
»
Questions
»
element belongs to a collection
Rank: Member Groups: Registered
Joined: 19/11/2013(UTC) Posts: 17
|
Hi, I have the question like this: Is it possible to obtain a result depending on whether the variable belongs to the collection? I mean the construction: if x "belongs to" {1, 2, 4, 8} then x=0 else x=111 or even if x "belongs to" {1, 2, 4, 8} else if x "belongs to {33, 45, 11) then x=99 else x=111 Thanks for an any response. Jadalbert
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/03/2016(UTC) Posts: 275 Was thanked: 91 time(s) in 57 post(s)
|
|
|
1 user thanked alyles for this useful post.
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,868 Was thanked: 980 time(s) in 808 post(s)
|
Originally Posted by: Jadalbert I have the question like this: Is it possible to obtain a result depending on whether the variable belongs to the collection? This is too vague for real answer. Yes, you can locate elements of an array that belongs as well to another array. Please, visit an extensive example, posted next few minutes: "Locate in array" In simple one array is much simpler, please let know if desired. Cheers.
|
|
|
|
Rank: Member Groups: Registered
Joined: 19/11/2013(UTC) Posts: 17
|
Thank You both for help. I tested both example and it works. But I dont understand how can I add new line to method (function) cases()? If it is the function cases(), may be I'm wrong. I mean: x := {1 if ...; 2 otherwise
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,868 Was thanked: 980 time(s) in 808 post(s)
|
Originally Posted by: Jadalbert But I don't understand how can I add new line to method (function) cases()? ... like this once you have if/otherwise [Cases], click right hand most place holder, coma twice for one more if... again coma twice like before, DIY. Cheers.
|
|
|
|
Rank: Member Groups: Registered
Joined: 19/11/2013(UTC) Posts: 17
|
Originally Posted by: Jean Giraud Originally Posted by: Jadalbert But I don't understand how can I add new line to method (function) cases()? ... like this once you have if/otherwise [Cases], click right hand most place holder, coma twice for one more if... again coma twice like before, DIY. Cheers. Ok, it works. But, I must use SEMICOLON twice. May be it is the same as coma (or comma) in real english. Im from Poland and my English is from school. Anyway - thank You for help. Jadalbert
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,639 Location: Italy Was thanked: 1323 time(s) in 873 post(s)
|
Originally Posted by: Jadalbert But, I must use SEMICOLON twice. That's because the more correct answer about arguments or decimal separators would be "press your argument separator" or "press your decimal separtor", since you can customize them in Tools > Options |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
SMath Studio Forum
»
SMath Studio
»
Questions
»
element belongs to a collection
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.