Hi Charles,

WC> Lst: ["Charlie" 120912 "Peter" 239823 "Sam" 9238923 "Tiana" 92348]
WC> I want to find "Sam" and retrieve his ID
WC> I them want to remove Sam his ID from Lst: and append it to the end of
WC> Lst:

I started tinkering with something a while back that may be useful to
you. Consider it a starting point if nothing else.

    move: func [
        "Moves the first instance of value, if found, to a new position in the 
series."
        series [series!]
        value
        /head "Move to the head of the series"
        /tail "Move to the tail of the series"
        /to   "Move to an absolute position in the series"
            index [number! logic! pair!] "Can be positive, negative, or zero"
        /skip "Move forward or backward from the current position"
            offset [number! logic! pair!] "Can be positive, negative, or zero"
        /part "Move the given number of items"
            range [number! series! pair!]
        ;/all "move all instances of value" ; ???
        /local pos dest sw*
    ] [
        sw*: system/words
        either none? pos: find/only series value [none] [
            either part [
                value: copy/part pos range
                remove/part pos range
            ][
                value: first pos
                remove pos
            ]
            dest: any [
                all [head  sw*/head series]
                all [tail  sw*/tail series]
                all [to    at series index]
                all [skip  sw*/skip pos offset]
            ]
            either part [insert dest :value] [insert/only dest :value]
        ]
    ]

Anyone else who wants to improve it, please do so; or let me know what
doesn't work--or what you don't like--and I'll make notes here.

-- Gregg

-- 
To unsubscribe from the list, just send an email to rebol-request
at rebol.com with unsubscribe as the subject.

Reply via email to