Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Moving an element...

 [1/5] from: mgkiourt:otenet:gr at: 27-Sep-2001 18:52


I have thefollowing names:[ "Mike" "Helen" "George" "Liz" "Tom"] How can I move the first element to the fourth position and generally what will hapen? Thanks.

 [2/5] from: al:bri:xtra at: 28-Sep-2001 4:12


> I have thefollowing > names:[
<<quoted lines omitted: 4>>
> "Tom"] > How can I move the first element to the fourth position and generally what
will hapen?
>> Names: ["Mike" "Helen" "George" "Liz" "Tom"]
== ["Mike" "Helen" "George" "Liz" "Tom"]
>> Name: pop Names
== "Mike"
>> insert at Names 3 Name
== ["Liz" "Tom"]
>> names
== ["Helen" "George" "Mike" "Liz" "Tom"] You might have to change the 3 to 4 or 2 depending upon your intent. Source for 'pop was published earlier. Andrew Martin ICQ: 26227169 http://zen.scripterz.org

 [3/5] from: mgkiourt:otenet:gr at: 27-Sep-2001 20:48


----- Original Message ----- From: Andrew Martin <[Al--Bri--xtra--co--nz]> To: <[rebol-list--rebol--com]> Sent: Thursday, September 27, 2001 7:12 PM Subject: [REBOL] Re: Moving an element...
> > I have thefollowing > > names:[
<<quoted lines omitted: 4>>
> > "Tom"] > > How can I move the first element to the fourth position and generally
what
> will hapen? > >> Names: ["Mike" "Helen" "George" "Liz" "Tom"]
<<quoted lines omitted: 6>>
> == ["Helen" "George" "Mike" "Liz" "Tom"] > You might have to change the 3 to 4 or 2 depending upon your intent.
Source
> for 'pop was published earlier. >
What does pop mean? I receive the following message: Script Error: Name has no value

 [4/5] from: al:bri:xtra at: 28-Sep-2001 6:01


> What does pop mean? I receive the following message: Script Error: Name
has no value You need the 'pop function: Pop: function [ "Returns the first value in a series and removes it from the series." Stack [series! port! bitset!] "Series at point to pop from." ][ Value ][ Value: pick Stack 1 remove Stack :Value ] I hope that helps! Andrew Martin ICQ: 26227169 http://zen.scripterz.org

 [5/5] from: ammoncooke::yahoo::com at: 27-Sep-2001 13:21


Here: Push: func [ "Inserts a value into a series and returns the series head." Stack [series! port! bitset!] "Series at point to insert." Value [any-type!] /Only "The value to insert." ][ head either Only [ insert/only Stack :Value ][ insert Stack :Value ] ] Pop: function [ "Returns the first value in a series and removes it from the series." Stack [series! port! bitset!] "Series at point to pop from." ][ Value ][ Value: pick Stack 1 remove Stack :Value ] two functions created by Andrew. They are very useful. I think you can put them in user.r to make them available to all scripts, or just put them in the script you want to use them from. ;) Enjoy!! Ammon

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted