Welcome Guest! To enable all features please Login or Register.

Error

 Previous Topic Next Topic
 Jadalbert #1 Posted : 12 July 2019 14:26:36(UTC) Rank: NewbieGroups: Registered Joined: 19/11/2013(UTC)Posts: 9 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=111or evenif x "belongs to" {1, 2, 4, 8} else if x "belongs to {33, 45, 11) then x=99 else x=111Thanks for an any response.Jadalbert
 Wanna join the discussion?! Login to your SMath Studio Forum forum accountor Register a new forum account.
 alyles #2 Posted : 12 July 2019 15:27:29(UTC) Rank: Advanced MemberGroups: Registered Joined: 23/03/2016(UTC)Posts: 191Was thanked: 65 time(s) in 41 post(s) Perhaps something like this? elementsbelongs.sm (5kb) downloaded 8 time(s).Edited by user 12 July 2019 15:31:11(UTC)  | Reason: Not specified Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW 1 user thanked alyles for this useful post. on 12/07/2019(UTC)
 Jean Giraud #3 Posted : 13 July 2019 16:45:58(UTC) Rank: Advanced MemberGroups: Registered Joined: 04/07/2015(UTC)Posts: 3,887Was thanked: 699 time(s) in 547 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.
 Jadalbert #4 Posted : 13 July 2019 17:10:28(UTC) Rank: NewbieGroups: Registered Joined: 19/11/2013(UTC)Posts: 9 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
 Jean Giraud #5 Posted : 14 July 2019 01:29:29(UTC) Rank: Advanced MemberGroups: Registered Joined: 04/07/2015(UTC)Posts: 3,887Was thanked: 699 time(s) in 547 post(s) Originally Posted by: Jadalbert But I don't understand how can I add new line to method (function) cases()?... like thisonce you have if/otherwise [Cases], click right hand most place holder,coma twice for one more if... again coma twice like before, DIY.Cheers.
 Jadalbert #6 Posted : 15 July 2019 14:29:29(UTC) Rank: NewbieGroups: Registered Joined: 19/11/2013(UTC)Posts: 9 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 thisonce 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
 Davide Carpi #7 Posted : 15 July 2019 14:41:38(UTC) Rank: Advanced MemberGroups: Registered, Advanced MemberJoined: 13/01/2012(UTC)Posts: 2,193Location: ItalyWas thanked: 1105 time(s) in 726 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 please consider a donation to SMath Studio; for personal contributions to me: paypal.me/dcprojects
 Users browsing this topic
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.