Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: MRide on September 02, 2010, 09:41:11 pm

Title: list equal list if statement
Post by: MRide on September 02, 2010, 09:41:11 pm
Is it possible to have "If L1=L2"?
Specifically, I'm trying to add two lists together and see if they equal a third.  I realize this is possible through a For( loop, but it seems too simple not to have a command that does this.
Title: Re: list equal list if statement
Post by: _player1537 on September 02, 2010, 09:43:33 pm
If Min(L1=L2
Title: Re: list equal list if statement
Post by: MRide on September 02, 2010, 09:57:16 pm
Thanks, I thought it would be that simple.  I should really make sure I know all the list commands.
Title: Re: list equal list if statement
Post by: _player1537 on September 02, 2010, 11:06:29 pm
It actually took me a while to get that statement :P  I needed it for a project a long time ago :)
Title: Re: list equal list if statement
Post by: MRide on September 02, 2010, 11:12:56 pm
Oh, well now I don't feel so bad. :P
Title: Re: list equal list if statement
Post by: meishe91 on September 02, 2010, 11:18:50 pm
Why does that work exactly?
Title: Re: list equal list if statement
Post by: _player1537 on September 02, 2010, 11:21:23 pm
Ok, lets say L1 = {1,2,0,4} and L2 = {1,2,3,0}
L1 = L2 == {1,1,0,0}
min({1,1,0,0}) = 0

Now if L1 = {1,2,3,4} and L2 = {1,2,3,4}
L1 = L2 == {1,1,1,1}
min({1,1,1,1}) = 1
Title: Re: list equal list if statement
Post by: meishe91 on September 02, 2010, 11:28:02 pm
Oh, ok. So basically you're just testing to see if there is a zero in any of the boolean between the lists?
Title: Re: list equal list if statement
Post by: _player1537 on September 02, 2010, 11:29:45 pm
Yep, which would mean that one of the elements is not the same :)
Title: Re: list equal list if statement
Post by: DJ Omnimaga on September 02, 2010, 11:47:35 pm
WOW, thanks so much for this! I never thought about doing that. I remember back in 2002 or 2003 I wondered how to do that, and never figured out. Nice trick you got there!
Title: Re: list equal list if statement
Post by: Builderboy on September 03, 2010, 01:07:22 am
I love things like this :) Basic has its perks!
Title: Re: list equal list if statement
Post by: Deep Toaster on September 03, 2010, 05:46:26 pm
Yep, and there are still some crazy optimizations that I can never get no matter how long I stare at them :D
Title: Re: list equal list if statement
Post by: meishe91 on September 03, 2010, 06:07:26 pm
Yep, and there are still some crazy optimizations that I can never get no matter how long I stare at them :D

Like what?
Title: Re: list equal list if statement
Post by: Deep Toaster on September 03, 2010, 06:08:14 pm
Like binomcdf( (or pdf, I don't remember). I don't get how it works :P
Title: Re: list equal list if statement
Post by: DJ Omnimaga on September 03, 2010, 06:46:31 pm
Yeah same here. if you read one of the Illusiat 13 topics, Galandros explained it thoroughly and then I checked the TIBD page a few times. I never managed to understand how it works. so I stuck with a slower alternative x.x
Title: Re: list equal list if statement
Post by: Builderboy on September 03, 2010, 06:57:44 pm
I myself still dont understand how it works x.x its kinda weird
Title: Re: list equal list if statement
Post by: Deep Toaster on September 03, 2010, 06:58:32 pm
I don't even know what binomcdf does. Well, there are those who say it works, so I'll use it :)
Title: Re: list equal list if statement
Post by: meishe91 on September 03, 2010, 07:12:58 pm
Huh, maybe I'll look into it and try to explain it :) I know I've looked at it briefly but don't remember much. What do people use it for?
Title: Re: list equal list if statement
Post by: Deep Toaster on September 03, 2010, 07:20:10 pm
It's to replace seq(I,1,X somehow.

EDIT: It's here (http://www.unitedti.org/forum/index.php?s=4ba9d18da23e2eca59a12def3cb62411&showtopic=25&view=findpost&p=97478).
Title: Re: list equal list if statement
Post by: Builderboy on September 03, 2010, 07:23:31 pm
I know that its actually a statistical tool, but i have no idea how it manages to replace seq() o.O
Title: Re: list equal list if statement
Post by: Deep Toaster on September 03, 2010, 07:25:30 pm
Ugh, I'm trying to get it, but all the broken HTML in DarkerLine's post is really getting annoying :P
Title: Re: list equal list if statement
Post by: meishe91 on September 06, 2010, 10:08:34 pm
Ya, I tried to read it too. I understood it but I've forgotten now. If I remember though, though I'll read it again later to help, most of the replacement is because it is just a faster routine. But I'd have to check back and make sure.
Title: Re: list equal list if statement
Post by: _player1537 on September 06, 2010, 11:02:58 pm
Btw, I wrote a quick C# application that takes a webpage, and strips the stuff inside [ ], makes it soooo muucchhh easier to read, does anyone want me to post the non HTML filled text?
Title: Re: list equal list if statement
Post by: DJ Omnimaga on September 07, 2010, 12:13:26 am
Mhmm that seems like a nice idea, it would make certain forum posts much easier to read
Title: Re: list equal list if statement
Post by: Deep Toaster on September 07, 2010, 07:19:55 pm
Okay, so as far as I can figure out, binomcdf(N,0 takes a probability (0 in this case) and somehow throws out a binomial list, and with 0, the list is N elements of 1, as in {1,1,1,.... Adding a cumSum( before it adds the ones to each total, resulting in {1,2,3,.... Somehow, it's faster than seq(I,I,1,N, probably because of all the floating-points used in the second :P
Title: Re: list equal list if statement
Post by: Builderboy on September 07, 2010, 07:22:38 pm
Interesting...  And somehow you can use this for any combination of sequences?
Title: Re: list equal list if statement
Post by: meishe91 on September 07, 2010, 07:30:22 pm
No, I haven't had time to look into this yet but I remember this part. It doesn't work for all sequences, such as ones including lists. And although it should always be faster than a sequence that is replaced by this it is not always smaller.
Title: Re: list equal list if statement
Post by: Deep Toaster on September 07, 2010, 07:40:10 pm
I think it's only used for a list of {1,2,3,....
Title: Re: list equal list if statement
Post by: Builderboy on September 07, 2010, 07:41:29 pm
But i think if you were given a list like that, you could square it and get a polynomial list.  I think any linear list can be transformed into a function if you mess with it enough o.O
Title: Re: list equal list if statement
Post by: meishe91 on September 07, 2010, 07:41:29 pm
Well I meant for seq( commands that contain a list inside of them. Unless I understood Builder's question wrong.
Title: Re: list equal list if statement
Post by: Deep Toaster on September 07, 2010, 07:52:26 pm
But i think if you were given a list like that, you could square it and get a polynomial list.  I think any linear list can be transformed into a function if you mess with it enough o.O

When it gets complicated enough you might as well use seq( :P

But after a couple of tries, the binomcdf( thing creates a list of 100 elements in just 2 seconds, compared to 8.6 for the seq( equivalent, so it's gonna be faster for most cases, unless you need something really complex :P