Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@afeinberg
Created January 3, 2011 09:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afeinberg/763280 to your computer and use it in GitHub Desktop.
Save afeinberg/763280 to your computer and use it in GitHub Desktop.
Thomas Friedman AI
(ns friedman)
;; Inspired by ``A Grammar for a Subset of English'', PAIP by Norvig pp. 35-36
(defn one-of [lst]
(nth lst (rand-int (count lst))))
(defn common-occupation []
(one-of '("barber" "cab driver" "teacher" "fisherman" "doctor")))
(defn capital-of-developing-country []
(one-of '("Lagos" "Minsk" "Kuala Lumpur" "Cairo" "Caracas")))
(defn anecdote []
(one-of '("about how they bought apples from Spain via a cell-phone"
"that the playing field is level"
"there are unemployed bankers")))
(defn unsupported-conclusion []
(one-of '("the world is flat." "the sky is green." "the moon is made of cheese.")))
(defn friedman []
(str "One " (common-occupation) " in " (capital-of-developing-country)
" told me " (anecdote) ", then I realized " (unsupported-conclusion)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment