Author Topic: How does this line of code work?  (Read 6431 times)

0 Members and 1 Guest are viewing this topic.

Offline holmes221b

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 282
  • Rating: +13/-1
  • RESISTANCE IS FUTILE.
    • View Profile
    • My Livejournal
How does this line of code work?
« on: December 11, 2010, 01:35:38 pm »
I was teaching my mom a little bit about using TI-Basic last night while we were waiting for our flu shots, and we ended up trying to reverse engineer one of the programs on my calc--one that I didn't write myself--and we got stuck on this one line:
Code: [Select]
:sum(2(Ans=3)+4(Ans=5
Could someone please explain how this line works for us?

Spoiler For "Projects":
Spoiler For "Because Everyone Else Is":
*Sigh*
can we keep this on topic? The topic is about what the big thing might be, NOT SEX

SirCmpwn

  • Guest
Re: How does this line of code work?
« Reply #1 on: December 11, 2010, 01:36:30 pm »
sum( is used to get the sum of a list, that line shouldn't even work O.o
« Last Edit: December 11, 2010, 01:36:51 pm by SirCmpwn »

Offline holmes221b

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 282
  • Rating: +13/-1
  • RESISTANCE IS FUTILE.
    • View Profile
    • My Livejournal
Re: How does this line of code work?
« Reply #2 on: December 11, 2010, 01:40:07 pm »
A list? There's no mention of a list in the other half of the code, though.

Should I post the entire code for the program?
« Last Edit: December 11, 2010, 01:41:00 pm by holmes221b »

Spoiler For "Projects":
Spoiler For "Because Everyone Else Is":
*Sigh*
can we keep this on topic? The topic is about what the big thing might be, NOT SEX

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: How does this line of code work?
« Reply #3 on: December 11, 2010, 01:43:56 pm »
wow your mom learns basic!? O.O
I'm not a nerd but I pretend:

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: How does this line of code work?
« Reply #4 on: December 11, 2010, 01:44:21 pm »
Strange, I tried it on my TI-Nspire running 84+ mode and I get an ERR:DATA TYPE error. Did you run any assembly program recently?
wow your mom learns basic!? O.O
O.O

Offline holmes221b

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 282
  • Rating: +13/-1
  • RESISTANCE IS FUTILE.
    • View Profile
    • My Livejournal
Re: How does this line of code work?
« Reply #5 on: December 11, 2010, 01:49:18 pm »
wow your mom learns basic!? O.O
We were bored and she had left her Blackberry at the house, so I offered to teach her a little bit about programming calcs while we waited. I never leave the house without my 83+.

The only assembly programming I've ever run on my calc is the one that allows you to have lower-case text.

Spoiler For "Projects":
Spoiler For "Because Everyone Else Is":
*Sigh*
can we keep this on topic? The topic is about what the big thing might be, NOT SEX

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: How does this line of code work?
« Reply #6 on: December 11, 2010, 01:53:37 pm »
haha your like me: completely addicted to calc stuff. in my class they already say things like: "when are you going to use your calc as an internet browser" and "what did you ask for birthday present? a new calc? " lol :w00t:
I'm not a nerd but I pretend:

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: How does this line of code work?
« Reply #7 on: December 11, 2010, 01:55:35 pm »
^ my life story ^

and linux :P

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: How does this line of code work?
« Reply #8 on: December 11, 2010, 01:57:07 pm »
i dont use linux. i cant get it on my PC, unfortunately :hyper: I :hyper: Lost :hyper: The :hyper: Game :hyper::hyper::hyper::hyper::hyper::hyper::hyper::hyper::hyper::hyper::hyper::hyper:
I'm not a nerd but I pretend:

Offline FinaleTI

  • Believe in the pony that believes in you!
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1830
  • Rating: +121/-2
  • Believe in the pony that believes in you!
    • View Profile
    • dmuckerman.tumblr.com
Re: How does this line of code work?
« Reply #9 on: December 11, 2010, 02:00:19 pm »
That's an odd line.
From what I can see, unless Ans is a list, you get an error.
So 3:sum(2(Ans=3)+4(Ans=5) gives me an ERR:DATA TYPE, while {3}:sum(2(Ans=3)+4(Ans=5) gives me 2.
It would seem only the first list entry affects it though, as {3,2}:sum(2(Ans=3)+4(Ans=5) just returns 2.


Spoiler For Projects:

My projects haven't been worked on in a while, so they're all on hiatus for the time being. I do hope to eventually return to them in some form or another...

Spoiler For Pokemon TI:
Axe port of Pokemon Red/Blue to the 83+/84+ family. On hold.

Spoiler For Nostalgia:
My big personal project, an original RPG about dimensional travel and a few heroes tasked with saving the world.
Coding-wise, on hold, but I am re-working the story.

Spoiler For Finale's Super Insane Tunnel Pack of Doom:
I will be combining Blur and Collision Course into a single gamepack. On hold.

Spoiler For Nostalgia Origins: Sky's Story:
Prequel to Nostalgia. On hold, especially while the story is re-worked.

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: How does this line of code work?
« Reply #10 on: December 11, 2010, 02:02:19 pm »
Ahh, right, passing a list would do it.  And actually, its not that only the first element matters... try {2,5} vs {2,4} to see what I mean
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

Offline holmes221b

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 282
  • Rating: +13/-1
  • RESISTANCE IS FUTILE.
    • View Profile
    • My Livejournal
Re: How does this line of code work?
« Reply #11 on: December 11, 2010, 02:29:25 pm »
haha your like me: completely addicted to calc stuff. in my class they already say things like: "when are you going to use your calc as an internet browser" and "what did you ask for birthday present? a new calc? " lol :w00t:
It took a lot of begging to get my first calc--they didn't like the idea of giving me something that could distract me in classes (I have ADHD, which means I have problems with focusing/paying attention), so it wasn't until 10th grade that I finally got one, when the teacher recommended that we had a calc for graphing (before that I used my mom's old BA-II).

That's an odd line.
From what I can see, unless Ans is a list, you get an error.
So 3:sum(2(Ans=3)+4(Ans=5) gives me an ERR:DATA TYPE, while {3}:sum(2(Ans=3)+4(Ans=5) gives me 2.
It would seem only the first list entry affects it though, as {3,2}:sum(2(Ans=3)+4(Ans=5) just returns 2.
So how does it make a list without making a list?
Code: ("full code") [Select]
:Pause randInt(1,6,5
:sum(2(Ans=3)+4(Ans=5

Spoiler For "Projects":
Spoiler For "Because Everyone Else Is":
*Sigh*
can we keep this on topic? The topic is about what the big thing might be, NOT SEX

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: How does this line of code work?
« Reply #12 on: December 11, 2010, 02:31:04 pm »
Well, first of all, that pause line should not have changed Ans, second... since when does ranint take three arguments? O_o
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

Offline FinaleTI

  • Believe in the pony that believes in you!
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1830
  • Rating: +121/-2
  • Believe in the pony that believes in you!
    • View Profile
    • dmuckerman.tumblr.com
Re: How does this line of code work?
« Reply #13 on: December 11, 2010, 02:36:25 pm »
A third argument makes it create a list of trials, with the third argument being the dimensions of the list/number of trials.


Spoiler For Projects:

My projects haven't been worked on in a while, so they're all on hiatus for the time being. I do hope to eventually return to them in some form or another...

Spoiler For Pokemon TI:
Axe port of Pokemon Red/Blue to the 83+/84+ family. On hold.

Spoiler For Nostalgia:
My big personal project, an original RPG about dimensional travel and a few heroes tasked with saving the world.
Coding-wise, on hold, but I am re-working the story.

Spoiler For Finale's Super Insane Tunnel Pack of Doom:
I will be combining Blur and Collision Course into a single gamepack. On hold.

Spoiler For Nostalgia Origins: Sky's Story:
Prequel to Nostalgia. On hold, especially while the story is re-worked.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: How does this line of code work?
« Reply #14 on: December 11, 2010, 02:40:07 pm »
ah, so the no-list->list problem is solved??
I'm not a nerd but I pretend: