On Sun, 20 Dec 1998, yehuda wrote: > Hi > > I have, in a list, the names of the 12 months. > How can I create from it the following output? > > > J F M A M J J A S O N D > a e a p a u u u e c o e > n b r r y n l g p t v c > u r c i e y u t o e e > a u h l s e b m m > r a t m e b b > y r b r e e > y e r r > r > > After 10 minutes of fiddling, I got the following source to work :) Displays the exact same output using recursion. Comes with both English and French version, because french is my native language, and frankly, I think the months in english sound bad :) One problem though: When I run the display_months a second time, the logo interpreter seems to enter an infinite loop (I even have to kill my Xterm because interruption doesn't work :) I tested the program with UCBLogo for UNIX, and it uses no library procedures. Regards (and a merry Christmas, Hannukah or Ramadan), -- Tennessee Carmel-Veilleux (Coordonator of Digital Meltdown) veilleux@ameth.org (www.ameth.org/~veilleux) ICQ ID : 8604827 Support Linux ! (www.linux.org;www.gnu.org) 1.99$ CD->(www.cheapbytes.com) ||*|| This message was written in Canada / Ce message a ete ecrit au Canada
to init
make "monthlist [January February March April May June July August ~
September October November December]
make "francais 0
make "current_height 1
end
to initialisation ; French months, I won't forget my native language this
; Christmas ;)
make "monthlist [Janvier Fevrier Mars Avril Mai Juin Juillet ~
Aout Septembre Octobre Novembre Decembre]
make "francais 1
make "current_height 1
end
to display_months
make "current_height 1
ifelse (:francais = 1) [
print [Au revoir 1998 !!!]
] [
print [Bye bye 1998 !!!]
]
do_display current_height
end
;Ahhh, yet again recursion saves us trouble :)
to do_display :Height
local "number_written
local "current_word
make "number_written 0
type "\ \ \ \ \
repeat (count :monthlist) [
make "current_word (item repcount :monthlist)
ifelse (or ((count :current_word) > :height)
((count :current_word) = :height)) [
type (item :height :current_word)
type "\ \ \
make "number_written 1
] [
type "\ \ \ \
]
]
print (char 32)
if (:number_written = 0) [ stop ]
do_display (:height + 1)
end
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