Mad Libs: Difference between revisions

Added 11l
m (added related tasks.)
(Added 11l)
Line 28:
{{Template:Strings}}
<br><br>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>V template = ‘<name> went for a walk in the park. <he or she>
found a <noun>. <name> decided to take it home.’
 
F madlibs(template)
print("The story template is:\n"template)
V fields = sorted(Array(Set(re:‘<[^>]+>’.find_strings(template))))
V values = input("\nInput a comma-separated list of words to replace the following items\n #.: ".format(fields.join(‘,’))).split(‘,’)
V story = template
L(f, v) zip(fields, values)
story = story.replace(f, v)
print("\nThe story becomes:\n\n"story)
 
madlibs(template)</lang>
 
{{out}}
<pre>
The story template is:
<name> went for a walk in the park. <he or she>
found a <noun>. <name> decided to take it home.
 
Input a comma-separated list of words to replace the following items
<he or she>,<name>,<noun>: She,Monica L.,cockerel
 
The story becomes:
 
Monica L. went for a walk in the park. She
found a cockerel. Monica L. decided to take it home.
</pre>
 
== {{header|Ada}} ==
1,480

edits