Author Topic: List help  (Read 3053 times)

0 Members and 1 Guest are viewing this topic.

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
List help
« on: November 16, 2007, 01:44:00 am »
What would be the fastest way to move every value in a list up one position in the list (thus deleting the last number in the list, and adding a new one at the beginning)?

Example:
{1,2,3,4,5->L1
//What would I do here?
#->L1(1
L1 = {#,1,2,3,4
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

Offline JonimusPrime

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 389
  • Rating: +25/-5
    • View Profile
    • Jonimoose.net
List help
« Reply #1 on: November 16, 2007, 02:06:00 am »
c1-->
CODE
ec1
Agument({#},L1->
dim(L1)-1->L1c2
ec2
that should do it but ti think I spelled that comand wrong.

"Always code as if the person who will maintain your code is a maniac serial killer that knows where you live" -Unknown

"If you've done something right no one will know that you've done anything at all" -Futurama

"Have a nice day, or not, the choice is yours." Tom Steiner

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
List help
« Reply #2 on: November 16, 2007, 04:00:00 am »
Augment*?

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
List help
« Reply #3 on: November 16, 2007, 09:46:00 am »
Sweet it worked :)smile.gif Thanks.
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

Offline Speler

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 857
  • Rating: +6/-2
    • View Profile
List help
« Reply #4 on: November 16, 2007, 02:15:00 pm »
No problem (See!  I can be helpful sometimes!)

Offline JonimusPrime

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 389
  • Rating: +25/-5
    • View Profile
    • Jonimoose.net
List help
« Reply #5 on: November 17, 2007, 05:32:00 am »
QuoteBegin-Super Speler+16 Nov, 2007, 20:15-->
QUOTE (Super Speler @ 16 Nov, 2007, 20:15)
No problem (See!  I can be helpful sometimes!)  

 Wait I posted the code Not you Speler?   :???:confus.gif

"Always code as if the person who will maintain your code is a maniac serial killer that knows where you live" -Unknown

"If you've done something right no one will know that you've done anything at all" -Futurama

"Have a nice day, or not, the choice is yours." Tom Steiner

Offline Speler

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 857
  • Rating: +6/-2
    • View Profile
List help
« Reply #6 on: November 17, 2007, 06:56:00 am »
I was posting in the wrong topic... sorry.

Offline JoostinOnline

  • LV2 Member (Next: 40)
  • **
  • Posts: 24
  • Rating: +0/-1
    • View Profile
List help
« Reply #7 on: November 17, 2007, 09:16:00 am »
QuoteBegin-Super Speler+17 Nov, 2007, 12:56-->
QUOTE (Super Speler @ 17 Nov, 2007, 12:56)
I was posting in the wrong topic... sorry.

Of course you were :angel:ange.gif
"Mac's are the Perfect Computer", said the Perfect Idiot.

Harrierfalcon

  • Guest
List help
« Reply #8 on: November 17, 2007, 09:40:00 am »
c1-->
CODE
ec1?List(cumSum(L1→L1c2
ec2(A lot faster during 100 repetitions) and smaller by 10 bytes.

Offline simplethinker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 695
  • Rating: +16/-5
  • snjwffl
    • View Profile
List help
« Reply #9 on: November 17, 2007, 10:26:00 am »
That cuts out the first element and doesn't add on a new one.

@trevmeister66, if you wanted to move everything down (left in your list) and cut off the first element and add a new number to the end(which is the exact opposite of what you're doing now) you can use c1-->
CODE
ec1?List(cumsum(augment(L1,{Nc2
ec2
which is 7 shorter.  All you would have to do is switch your list around.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true." -- Professor Robert Silensky



Chip's Challenge: ħ%