Rust asked, "How is mathematics in Göttingen now that it has been freed of the Jewish influence?" Hilbert replied, "Mathematics in Göttingen? There is really none any more."
You see, mathematics is a purely jewish scam. Kill all jews, and you will kill mathematics.
Name:
Anonymous2011-07-24 21:42
>>28
I need Nial/Refal style list processing, with some elements from Factor and a good macro/quasiquoting facility. Has offers neither.
I prefer writing
// Usage: generate {sentence}
Grammar -> split {|} {sentence -> (noun_phrase verb_phrase)
|noun_phrase -> (Article Noun)
|verb_phrase -> (Verb noun_phrase)
|Article -> the a
|Noun -> man ball woman table
|Verb -> hit took saw liked}
instead of
(defparameter *grammar*
'((sentence -> (noun-phrase verb-phrase))
(noun-phrase -> (Article Noun))
(verb-phrase -> (Verb noun-phrase))
(Article -> the a)
(Noun -> man ball woman table)
(Verb -> hit took saw liked))
"A grammar for a trivial subset of English.")
(defun generate (phrase)
"Generate a random sentence or phrase"
(cond ((listp phrase)
(mappend #'generate phrase))
((rewrites phrase)
(generate (random-elt (rewrites phrase))))
(t (list phrase))))
(defun generate-tree (phrase)
"Generate a random sentence or phrase,
with a complete parse tree."
(cond ((listp phrase)
(mapcar #'generate-tree phrase))
((rewrites phrase)
(cons phrase
(generate-tree (random-elt (rewrites phrase)))))
(t (list phrase))))
(defun mappend (fn list)
"Append the results of calling fn on each element of list.
Like mapcon, but uses append instead of nconc."
(apply #'append (mapcar fn list)))
(defun rule-rhs (rule)
"The right hand side of a rule."
(rest (rest rule)))
(defun rewrites (category)
"Return a list of the possible rewrites for this category."
(rule-rhs (assoc category *grammar*)))