Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

finite state machines in scheme

Name: Anonymous 2013-03-01 3:25

yea. anyone got sum kool examplez?

Name: Anonymous 2013-03-03 7:41

>>26
Made of cons-pairs. SEXPs allow stuff like (a b . c), created with (cons a (cons b c)). Atomic lists don't allow that.

>>27
But dude, the thing is that "A*B+C" is not a Symta datastructure.
"A*B+C" is just (`+` (`*` A B) C), like Lisp's "'s" is just (quote s)

To make an analogy, you could write a Python parser in Python which produces its AST as a Python object and manipulate Python code that way
Nope.
Python's AST would be impractically hard to manipulate.
See http://norvig.com/python-lisp.html


Python does not have macros. Python does have access to the abstract syntax tree of programs, but this is not for the faint of heart. On the plus side, the modules are easy to understand, and with five minutes and five lines of code I was able to get this:

>>> parse("2 + 2")
['eval_input', ['testlist', ['test', ['and_test', ['not_test', ['comparison',
 ['expr', ['xor_expr', ['and_expr', ['shift_expr', ['arith_expr', ['term',
  ['factor', ['power', ['atom', [2, '2']]]]], [14, '+'], ['term', ['factor',
   ['power', ['atom', [2, '2']]]]]]]]]]]]]]], [4, ''], [0, '']]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List