Don't have an account? Register now to chat, post, use our tools, and much more.
This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Calculator Programming subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

General Coding and Design => Calculator Programming
Author Message
Babyboy

Joined: 11 Jun 2003
Posts: 499

 Posted: 24 Oct 2011 12:48:28 pm    Post subject: hello everyone, its been a while, usually im good at figuring things myself, but i cant figure how to even google this. if arrayname.contains(number) = true return the position in the array of the found number arrayname(1,2,3,4,5,6,7) as integer if arrayname.contains(7) = true intIndexNumber= ****the code i need to return the position of the number 7)********** any ideas?
Xeda112358

Active Member

Joined: 19 May 2009
Posts: 520

 Posted: 24 Oct 2011 06:37:34 pm    Post subject: I am absolutely not familiar with that language whatsoever. I do know that if I were to do this in TI-BASIC, I would do 1+sum(not(cumSum(7=L1 I don't know if the language you are working with would return a list of boolean comparisons, but if it does, you can take advantage of that. (meaning in TI-BASIC, 7=L1 using your array above would return {0,0,0,0,0,0,1})Last edited by Guest on 24 Oct 2011 06:41:12 pm; edited 1 time in total
Babyboy

Joined: 11 Jun 2003
Posts: 499

 Posted: 25 Oct 2011 01:16:54 pm    Post subject: Ok, I spent years with Ti-Basic, but i have no idea what the F*** that code does, could you take me through it?
Xeda112358

Active Member

Joined: 19 May 2009
Posts: 520

 Posted: 25 Oct 2011 11:58:58 pm    Post subject: 1+sum(not(cumSum(7=L1 So to break it down, say we have L1 be {1,3,7,4,3,3,1,2} 7=L1 returns {0,0,1,0,0,0,0,0} cumSum( of that returns {0,0,1,1,1,1,1,1} not( of that returns {1,1,0,0,0,0,0,0} sum( of that returns 2 add 1 to get the location of the first 7 So what if there are two sevens? {1,3,7,4,3,7,1,2} Code: ``` {0,0,1,0,0,1,0,0}     7=L1 {0,0,1,1,1,2,2,2}     cumSum( {1,1,0,0,0,0,0,0}     not( 2                     sum( 3                     1+ ```Last edited by Guest on 26 Oct 2011 12:00:52 am; edited 1 time in total
Babyboy

Joined: 11 Jun 2003
Posts: 499

 Posted: 27 Oct 2011 01:31:48 pm    Post subject: F******* beautiful
Xeda112358

Active Member

Joined: 19 May 2009
Posts: 520

 Posted: 31 Oct 2011 10:21:21 pm    Post subject: Did it manage to help your problem? Or do you still need a solution?
 Display posts from previous: All Posts Oldest FirstNewest First
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
 Page 1 of 1 » All times are GMT - 5 Hours