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

Re: LOGO-L> Re: logo-l-digest V16 #12



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.

Peter Tomcsanyi
---------------------------------------------------------------
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