From: Douglas Livingstone Date: 2006-05-24T12:54:52+09:00 Subject: Re: Zed and Luis drop the bomb on Ruby's poor performance 2006/5/24, James Britt : > > > $ cat lispify.rb > > #!/usr/local/bin/ruby > > > > def lispify(code) > > code.gsub!(/[:,]/, '') > > code.gsub!(/\[/, '(') > > code.gsub!(/\]/, ')') > > end > > Topher's article[0] at RC&S might be of interest, too. > > gemp install sexp Nice link. Doing the hack job solution, taking parse_tree_show and appending sexp to it, gives: $ diff parse_tree_show parse_tree_lisp 44,48c44,48 < unless defined? $q then < pp result < else < p result < end --- > class Object; def to_sexp; inspect(); end; end > class Symbol; def to_sexp; id2name(); end; end > class Array; def to_sexp; "(#{map{|x| x.to_sexp }.join(' ')})"; end; end > > puts result.to_sexp Resulting in the probably-more-reliable-than-gsub result of: ((defn sum (scope (block (args a b) (return (call (lvar a) + (array (lvar b))))))) (lasgn a (lit 3)) (lasgn b (lit 4)) (lasgn c (fcall sum (array (lvar a) (lvar b)))) (fcall puts (array (lvar c)))) Douglas