It's hard to know if your being to specific and since Logo is a learning language a good problem to sort out for themselves (don't give the answer away :-)). But I think an extract with no randomness makes more sense. And it would simply be a matter of the user choosing if the element he/she wishes to extract should be random or not. Then you'd have a more basic function younger students are more likely to understand and build on. This would also simplify the output. There would be no need to return both what was extracted and what was left. Becuase they could simply use ITEM with the same argument they passed to extract to get what will be extracted. You would not need to remember to use ()'s when you use an argument and use first and last to extract the answers. make "alist [1 2 3] make "aitem 2 show item :aitem :alist 2 show extract :alist :aitem [1 3] make "aitem 1 + random count :alist show item :aitem :alist 3 show extract :alist :aitem [1 2] No first's, last's, ()'s or data you don't need or use. jstclair@omsd.cerf.fred.org wrote: > > Please reply to bh@anarres.CS.Berkeley.EDU (Brian Harvey) or > logo-l@gsn.org NOT logo-list@gsn.org or me. > > -John > --Message below re-posted by <jstclair@omsd.cerf.fred.org> > Date - 21 Jan 1998 21:30:24 GMT > >From - bh@anarres.CS.Berkeley.EDU (Brian Harvey) > To - jcstclair@omsd > Subject - Re: LOGO-L> eliminating items randomly from a list > Usenet: comp.lang.logo > ------------------ > Post Usenet mail to comp-lang-logo@ucbvax.berkeley.edu > ------------------ > > George Mills <mills@softronix.com> writes: > >What you want is the index ITEM recieved not the data it pointed at. > > I am beginning to think that what's needed is a new library procedure > called something like EXTRACT: > > to extract :stuff [:index 1+random count :stuff] [:sofar []] > if :index = 1 [output list (first :stuff) (se (reverse :sofar) (bf :stuff))] > output (extract (bf :stuff) (:index-1) (fput first :stuff :sofar)) > end > > Here's how it works: > > ? SHOW (EXTRACT [A B C D A B C D E] 6) > [B [A B C D A C D E]] > > With only one argument it would pick one at random. The typical use > would be to say > > to select > localmake "result extract :globalvariable > make "globalvariable last :result > output first :result > end > > What do you all think? > -- =============================================================== George Mills email: mills@softronix.com http://www.softronix.com The www page contains some very powerful educational software. Our single most important investment is our kids. --------------------------------------------------------------- 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