Jump to content

Mad Libs: Difference between revisions

43 bytes removed ,  9 years ago
Fixed Mathematica
(Made more functional)
(Fixed Mathematica)
Line 1,083:
InputString["Enter the filename of the story template:"]];
answers =
AssociationMap[
InputString[
"Enter a" <>
If[StringMatchQ[#, Alternatives @@ Characters["aeiou"] ~~ ___],
"n<", ~~ Alternatives @@ Characters["aeiou"] <>~~ "___], " <> # <>n", ":"] & /@ <>
" " <> StringTrim[StringCases[text#, RegularExpression["<[^" | ">"]+ <> ":"]] &,
StringReplaceUnion[StringCases[text, RegularExpression["<[^>]+>"] -> "``"]]]];</lang>
"<" | ">"];
Print[StringReplace[text, Normal[answers]]];</lang>
Print[ToString[
StringForm @@
Prepend[answers,
StringReplace[text, RegularExpression["<[^>]+>"] -> "``"]]]];</lang>
{{out}}
<pre>George went for a walk in the park. he
Cookies help us deliver our services. By using our services, you agree to our use of cookies.