> Hello Erich, > > At 10:50 17.8.1998 +0100, you wrote: > >here is a dealer: > > > >to deal :n :set > >if :n = 0 [output []] > >localmake "picked pick :set > >output fput :picked deal :n - 1 remove :picked :set > >end > >... > >this is mswlogo code, > >so i guess it should work in ucblogo also, > >i am not sure if other dialects have pick > >and remove > > SuperLogo (Comenius Logo) has PICK but REMOVE is named BUTMEMBER and > LOCALMAKE is named LET. So this code may be used for Superogo: > > to deal :n :set > if :n = 0 [output []] > let "picked pick :set > output fput :picked deal :n - 1 butmember :picked :set > end > > A shorter solution is possible in SuperLogo: > > to deal1 :n :set > output item list 1 :n shuffle :set > end > > ITEM outputs a part of the list if its first input is a list: > show item [2 5] [a b c d e f g h i] > [b c d e f] > > SHUFFLE outputs a list containing the same elements as its input, just > their positions are randomly rearranged. > Which of the two would be more efficient? I know "remove" is expensive because it has to look up every element of the list to find out which ones to remove. And it has to run n times. On the other hand, I thing shuffing is more expensive. I believe it is done by swapping two randomly choosen elements of the list. And this is done m times, with m>n so that the we get a good shuffle. Do you know how lenguajes that have the "deal" function built-in (APL) do the dealing? .... What about integration and derivation procedures?, Has anyone done a LOGO implementation? --------------------------------------------------------------- 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