Mad Libs: Difference between revisions
Content deleted Content added
Took out a color setting line and addressed one memory issue that needs to be set to make program work on Commodore machines other than the 64. |
No edit summary |
||
Line 1,767: | Line 1,767: | ||
<pre>George went for a walk in the park. he |
<pre>George went for a walk in the park. he |
||
found a car. George decided to take it home.</pre> |
found a car. George decided to take it home.</pre> |
||
=={{header|Nanoquery}}== |
|||
<lang Nanoquery>def madlib(template) |
|||
// loop through and find/remove all of the replacements |
|||
replacements = {} |
|||
ind = 0 |
|||
while ind < len(template) |
|||
// check if we have found a replacement to perform |
|||
if template[ind] = "<" |
|||
// get the name of the replacement and add it to the list |
|||
// if we haven't already encountered it |
|||
ind += 1 |
|||
replace_name = "" |
|||
while template[ind] != ">" |
|||
replace_name += template[ind] |
|||
ind += 1 |
|||
end while |
|||
if not replace_name in replacements |
|||
replacements.append(replace_name) |
|||
end if |
|||
ind += 1 |
|||
else |
|||
ind += 1 |
|||
end if |
|||
end while |
|||
// prompt the user for replacement values |
|||
replacement_values = {} |
|||
for phrase in replacements |
|||
replacement_values.append(input("enter " + phrase + ": ")) |
|||
end for |
|||
println |
|||
// make replacements and output the story |
|||
ind = 0 |
|||
while ind < len(template) |
|||
// check if we have found a replacement to perform |
|||
if template[ind] = "<" |
|||
// get the name of the replacement |
|||
ind += 1 |
|||
replace_name = "" |
|||
while template[ind] != ">" |
|||
replace_name += template[ind] |
|||
ind += 1 |
|||
end while |
|||
// output the replacement |
|||
print replacement_values[replacements[replace_name]] |
|||
ind += 1 |
|||
else |
|||
print template[ind] |
|||
ind += 1 |
|||
end if |
|||
end while |
|||
end madlib |
|||
madlib("<name> went for a walk in the park. <he or she> " + \ |
|||
"found a <noun>. <name> decided to take it home.")</lang> |
|||
=={{header|Nim}}== |
=={{header|Nim}}== |