Removing an element from a list
Sorry, stupid question (beginner here): I can't find the answer: what is the easiest way to remove an element from a list?

mylist: ["1" "22" "333" "4444" "55555"]

This seems to work but... a little complicated?

remove skip mylist ((index? find mylist "333") - 1)

You can use: remove at mylist index? find mylist "333"

You can create then a function:

remove-value: func [ blk [ block! ] value [ any-type! ] ] [
   not error? try [ remove at blk index? find blk value ]

remove-value mylist "33"
== false
remove-value mylist "333"
== true
? mylist
MYLIST is a block of value: ["1" "22" "4444" "55555"]

Good luck with Rebol. It is a very practical language once we have mastered the notion of block! string! and object!
Not bad, but why use index? :
mylist: ["1" "22" "333" "4444" "55555"]
attempt [remove find mylist "333"]

'find return the block at the position of the value found, so you just need to 'remove there
'attempt is here to catch the error if the 'find don't match.

Enjoy Rebol
If you don't want to use 'attempt, the shortest one is:
if p: find mylist "333" [remove p]

Login required to Post.

Powered by RebelBB and REBOL