Mad Libs: Difference between revisions

Content added Content deleted
(Made more functional)
(Fixed Mathematica)
Line 1,083: Line 1,083:
InputString["Enter the filename of the story template:"]];
InputString["Enter the filename of the story template:"]];
answers =
answers =
AssociationMap[
InputString[
InputString[
"Enter a" <>
"Enter a" <>
If[StringMatchQ[#, Alternatives @@ Characters["aeiou"] ~~ ___],
If[StringMatchQ[#,
"n", ""] <> " " <> # <> ":"] & /@
"<" ~~ Alternatives @@ Characters["aeiou"] ~~ ___], "n", ""] <>
StringTrim[StringCases[text, RegularExpression["<[^>]+>"]],
" " <> StringTrim[#, "<" | ">"] <> ":"] &,
Union[StringCases[text, RegularExpression["<[^>]+>"]]]];
"<" | ">"];
Print[StringReplace[text, Normal[answers]]];</lang>
Print[ToString[
StringForm @@
Prepend[answers,
StringReplace[text, RegularExpression["<[^>]+>"] -> "``"]]]];</lang>
{{out}}
{{out}}
<pre>George went for a walk in the park. he
<pre>George went for a walk in the park. he