Removal or exclusion ?
[1/5] from: patrick:philipot:laposte at: 7-Jul-2003 18:40
Hi list
In terms of elegance and efficiency, which one do you choose ? remove-each or exclude
? or a third solution ?
My problem is to remove all the selected items of a text-list from the list-data. I have
got two ways to do that:
(1) remove-each x list-data [found? find mylist/picked x]
(2) s-temp: exclude list-data mylist/picked clear list-data append list-data s-temp
Unfortunately, in this particular case, one cannot use "list-data: exclude list-data
mylist/picked" because the resulting block is not associated to the list anymore.
The test example...
list-data: ["red" "green" "blue" "yellow" "white"]
lay: layout [
mylist: text-list 200x200 data list-data
button "Remove selected" 200 [
; remove-each x list-data [found? find mylist/picked x]
s-temp: exclude list-data mylist/picked clear list-data append list-data s-temp
show mylist
]
]
view center-face lay
Regards
Patrick
[2/5] from: antonr:iinet:au at: 8-Jul-2003 10:19
How about:
insert clear list-data exclude list-data mylist/picked
Anton.
[3/5] from: patrick:philipot:laposte at: 8-Jul-2003 8:59
Hi Anton,
>> insert clear list-data exclude list-data mylist/picked
I like the style and I was really looking for something like that, however
(at least with View 1.2.10) list-data is always empty.
See a simplified version
list-data: ["red" "green" "blue" "yellow" "white"]
picked: ["yellow" "green"]
insert clear list-data exclude list-data picked
print mold list-data ; == []
As I see it, list-data is cleared before the exclude is performed, therefore
giving an empty list.
Regards
Patrick
[4/5] from: nitsch-lists:netcologne at: 8-Jul-2003 9:14
Am Dienstag, 8. Juli 2003 02:19 schrieb Anton:
> How about:
>
> =09insert clear list-data exclude list-data mylist/picked
>
Thought that myself, but you clear the list-data before you exclude..
In Patricks example, the remove-each looks cleaner.
Efficience should not matter here.
> Anton.
> > Hi list
<<quoted lines omitted: 33>>
> > Regards
> > Patrick
-Volker
[5/5] from: antonr::iinet::net::au at: 8-Jul-2003 19:44
Ah.. you are right.
Perhaps if you don't want to use another word
then you could use:
do compose/only [insert clear list-data (exclude list-data mylist/picked)]
or
do compose/deep [insert clear list-data [(exclude list-data
mylist/picked)]]
But, you see the expression grows ever longer.
Anton.
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted