Jump to content
1980gamer

IN function?

Recommended Posts

I tried to search for this, but it didn't find anything.

 

I have not seen this, but would be a great function.  

IF X IN(1,3,5,7,11) then xxxx else yyyy

instead of IF X=1 or X=3 or X=5 or X=7 or X=11 then....

 

Or

 

IF X NOT IN(1,3,5,7,11) then  OH.. Never Mind.  I think just reverse the then and else?

 

Maybe:

CALL IN([1,2,3,4,5],X)  :: IF X=1 then xxxx else yyyy

 

 

Share this post


Link to post
Share on other sites

This will be in the next version of SXB TiCodEd, only with square brackets:

 

IF K IN[69,83,68,88] THEN <STMT1>

 

or 

 

IF K NOT IN[69,83,68,88] THEN <STMT1>

 

If testing goes well it will be released in two weeks with lots of other enhancements. It gets translated to IF K=69 OR K=83 OR K=68 OR K=88 THEN ... for the use with any Extended BASIC.

 

 

  • Like 2

Share this post


Link to post
Share on other sites

Hey I said in RXB I was going to make a new routine called SET[1,3,5,7,11] last year! 

Glad someone is reading my posts!

Share this post


Link to post
Share on other sites
44 minutes ago, RXB said:

Hey I said in RXB I was going to make a new routine called SET[1,3,5,7,11] last year! 

Glad someone is reading my posts!

Might have missed it, or maybe I think of SET  as "setting" a value, not comparing one.

 

Share this post


Link to post
Share on other sites
1 hour ago, 1980gamer said:

Might have missed it, or maybe I think of SET  as "setting" a value, not comparing one.

 

Google search:

How do you describe a set?
A set in mathematics is a collection of well defined and distinct objects, considered as an object in its own right. ... The most basic properties are that a set "has" elements, and that two sets are equal (one and the same) if and only if every element of one is an element of the other.Sep 15, 2012

 

What is sets and examples?
A set is a collection of elements or numbers or objects, represented within the curly brackets { }. For example: {1,2,3,4} is a set of numbers.Jul 19, 2020
 
What is set in math?
Set, In mathematics and logic, any collection of objects (elements), which may be mathematical (e.g., numbers, functions) or not. ... For example, the set of integers from 1 to 100 is finite, whereas the set of all integers is infinite. A set is commonly represented as a list of all its members enclosed in braces.
 
  • Like 1

Share this post


Link to post
Share on other sites

I am not a mathematician, I am a SQL developer.

image.thumb.png.6329a2cec319970acb897147a01cae62.png

This is what I think of when I hear SET.

Edited by 1980gamer
  • Like 2

Share this post


Link to post
Share on other sites
47 minutes ago, matthew180 said:

What about ON GOTO and ON GOSUB ?

With a non-contiguous set of numbers you would have to either work up a formula to convert the set to {1..x} or have dummy entries in the list.  I have done this in the past with a set of numbers like {1,2,4,6,8,9} and used a "dummy" line number in positions 3, 5, and 7 which go to a line which prints something like "THERE BE WHALES HERE" or jumps back to the beginning of the process which gave the errant value (to hopefully fix it.)

  • Like 1

Share this post


Link to post
Share on other sites

Ah, yes, I have not looked at anything BASIC or XB in a long time.  ON GOTO / GOSUB are limited to consecutive values then (and starting with 1?)  Well, sometimes you can make that happen, otherwise I supposed you have to just do the checks.  Although, there are a lot of tricks in BASIC for checking numbers and such.  I don't have any examples off-hand, but I have seen some pretty weird stuff in an IF statement.

Share this post


Link to post
Share on other sites
44 minutes ago, matthew180 said:

Ah, yes, I have not looked at anything BASIC or XB in a long time.  ON GOTO / GOSUB are limited to consecutive values then (and starting with 1?)  Well, sometimes you can make that happen, otherwise I supposed you have to just do the checks.  Although, there are a lot of tricks in BASIC for checking numbers and such.  I don't have any examples off-hand, but I have seen some pretty weird stuff in an IF statement.

Me too.  I don't really get these IF's some or most of the time!  I like human readable.  Being old and slow.

I guess I get the True or False variants, but I have seen some crazy stuff as well. 

 

That being said, I knew I had done something a few years ago in another program.....  I want to use it now.

I listed the program to notepad and was like.... WHAT WAS I SMOKING when I wrote this!

 

Not certain if it is genius or insanity?  But it certainly took me longer to figure out / remember what I was doing than it would have taken to just rewrite it!

 

Share this post


Link to post
Share on other sites
4 hours ago, matthew180 said:

ON GOTO / GOSUB are limited to consecutive values then (and starting with 1?)

Yup.

3 hours ago, 1980gamer said:

That being said, I knew I had done something a few years ago in another program.....  I want to use it now.

I listed the program to notepad and was like.... WHAT WAS I SMOKING when I wrote this!

Yup.

3 hours ago, 1980gamer said:

Not certain if it is genius or insanity?

  • Haha 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...