Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #59799
| From | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Rosetta: Mad Libs |
| Date | 2017-05-25 04:34 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <og5msg$1e1e$1@gioia.aioe.org> (permalink) |
> Then, find each replacement to be made within the story, ask
> the user for a word to replace it with, and make all the
> replacements.
>
> Stop when there are none left and print the final story.
>
> The input should be an arbitrary story in the form:
>
> <name> went for a walk in the park. <he or she>
> found a <noun>. <name> decided to take it home.
>
> Given this example, it should then ask for a name, a he or she
> and a noun (<name> gets replaced both times with the same
> value).
def mad_lib(template)
blanks = template.scan(/<.*?>/).uniq
puts "The template is:", template
story = template
blanks.each{|s|
print "Supply replacement for #{s}: "
story.gsub!(s, gets.strip)
}
puts ; puts "The story is:", story
end
mad_lib "<name> went for a walk in the park. <he or she>
found a <noun>. <name> decided to take it home."
===>
The template is:
<name> went for a walk in the park. <he or she>
found a <noun>. <name> decided to take it home.
Supply replacement for <name>: Hansel
Supply replacement for <he or she>: He
Supply replacement for <noun>: toad
The story is:
Hansel went for a walk in the park. He
found a toad. Hansel decided to take it home.
In Forth?
--
Much of what I'll be talking about today is taken from that excellent essay,
which includes incontrovertible mathematical and statistical proof that violent
crime bears a close, nearly direct, relationship to the presence of Blacks and
Mestizos in our midst.
nationalvanguard.org/2014/02/american-dissident-voices-america-race-and-violent-crime/
Back to comp.lang.forth | Previous | Next — Next in thread | Find similar | Unroll thread
Rosetta: Mad Libs "Robert L." <No_spamming@noWhere_7073.org> - 2017-05-25 04:34 +0000 Re: Rosetta: Mad Libs Julian Fondren <julian.fondren@gmail.com> - 2017-05-24 22:49 -0700
csiph-web