[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LOGO-L> choosing random elements (again)



Sorry to beat this subject to death, but I have made one more discovery
about the relative benefits of Frank's and George's methods of selecting
and eliminating random elements from a list.  As a prelude to this
discovery, I realized that I made another mistake in reporting what I had
done  (I said I had, after eliminating an item, then    run :item  to run
the newly-selected-and-eliminated procedure, but actually I had   run
:anitem, since  item  merely reports a number).  But in rechecking this
with both methods, I realized that George's method does not provide any
value to  "anitem.  I had wondered about this earlier, since I noted that
he used that variable in one of his two procedures without having ever
seemed to define it.  Frank's method clearly provides a value to "anitem.
Therefore, in a situation like mine where one wants to select and USE an
item for something, and then eliminate it, Frank's method is better.
George's method does not allow me to use the item which I have eliminated,
as far as I can tell.  But I'm wondering if George could simply add a line
to his procedure, the same line that Frank used  (make "anitem pick
:alist), or would that mess things up in some other way?  And if George
does not define "anitem, then how or why does he use it?

Also, in response to the suggestions from two other helpful people whose
suggestions included the word "remove," I must verify George's assertion
that MicroWorlds does not allow this use of remove... unfortunately it only
allows this word for removing turtles, pages, and variables, not items
within a list.

>to dropOneFrom :inlist
>if emptyp :inlist [op :inlist]
>op remove pick :inlist :inlist
>end

and
>If I understood your requirements, I think you want something like this:

>make "newlist remove pick :oldlist :oldlist

>Pick randomly picks one element from the old list, remove outputs a list
>with that element removed.  Hope this helps.


---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org.  Mail
questions about the list administration to logofdn@gsn.org.  To
unsubscribe send    unsubscribe logo-l    to majordomo@gsn.org.



Global SchoolNet Foundation - Linking Kids Around the World!
Copyright GSN - All Rights Reserved - Comments & Questions
Visit GSN's Global Schoolhouse for more exciting learning resources!
Search our Site - Home