won’t you

Nick Montfort · Poems

Originally published in print and on the Web in the “Open Source” issue of Increment. The original versions are very nicely illustrated but Increment’s Web page does not work properly as of 2022-04.

This is meant to work as a type-in computer program (a Web page with JavaScript in it) that all are welcome to study and modify. Of course, if you’re seeing this on the Web, you don’t need to type it in in the first place! Just copy the code and paste it into a text editor, then save it as something like “mine.html” — that will be your version.

won’t you generates sentences recursively, so sentence-like phrases can be embedded in larger sentences. Watch for a while and you’ll see that rarely, very long sentences are generated.

<html>
<head>
<meta http-equiv=" refresh" content="4">
<script>
var aux = ["", "can", "don't", "must", "will", "won't"],
    act = ["find", "know", "learn", "read", "say", "see"];
function pick(list) {
  return list[~~(Math.random() * list.length)];
}
function phrase() {
  var end = " it";
  if (Math.random() < .3) {
    end = " that " + phrase();
  }
  return "we " + pick(aux) + " " + pick(act) + end;
}
</script>
</head>
<body id=b style="margin: 20%" onload="b.innerHTML=phrase();">
</html>