Logo is well suited to explorations of natural language. This
is because Logo's data structures - words and lists - closely parallel
the words, phrases, and sentences that make up spoken and written
language.
For example, if we type
print sentence "strawberry
[ice cream]
Logo displays
strawberry ice cream
on the screen, having made a sentence out of the word "strawberry
and the list of two words [ice cream].
The instruction
print sentence [vanilla
fudge] [ice cream]
prints
vanilla fudge ice
cream
In Exploring
Language with Logo, Paul Goldenberg and Wally Feurzeig
begin with some gossip;
to gossip
output sentence who doeswhat
end
to who
output pick [Sandy Dale Dana Chris]
end
to doeswhat
output pick [cheats. [loves to walk.] [talks a
mile a minute] yells.]
end
Pick reports an item randomly picked from the
list that follows. Who reports a randomly chosen
name of a person. Doeswhat reports a randomly selected
verb phrase. Gossip puts the two together and reports
a sentence.
The instruction print gossip might display
Chris loves to walk.
or
Dana cheats.
or
Dale talks a mile
a minute.
or
Dale cheats.
or...
What if we change doeswhat to be:
to doeswhat
output pick [cheats. [loves to walk.] [talks a
mile a minute] yells.[ Ford Mustang.]]
end
We could end up with a non-sentence like
Dale Ford Mustang.
So with this playful exercise we can learn something about nouns
and verbs.

How about a program that pluralizes words?
to pluralize :singular
output word :singular "s
end
print pluralize "dog
dogs
print pluralize "cat
cats
print pluralize "box
boxs
Oops. Time to debug...
to pluralize :singular
if (last :singular) = "x [output word :singular "es]
output word :singular "s
end
print pluralize "box
boxes
Good.
print pluralize "mouse
mouses
looks like we have some more debugging to do...
Instead of being taught the rules of pluralization and then applying
them, Logo allows us to construct the rules, building them up from
a series of concrete cases.
There's much much more. Check out Paul
and Wally's book.
|