From: Brian Candler Date: 2009-08-10T21:10:11+09:00 Subject: Re: Kind of ParsTree for 1.9.1 Lui Core wrote: >> I think that's the point :-) You *have* to pass it a String source for >> it to parse. You can't take an object which Ruby has already parsed and >> installed, such as method(:foo) in this case, and get the sexp from the >> object. > > One way to generate AST from live object is to use method_missing, which > is applicable in 1.9 with pure ruby code. > > see > http://rubyquiz.com/quiz95.html That's not proper Ruby; I don't see any loops or conditional branches. I suspect this approach requires you to solve the halting problem. e.g. sxp { for i in 3..1.0/0 for j in 3..i for k in j..i for p in 3..i if i**p + j**p == k**p puts "fermat disproved: #{i}, #{j}, #{k}, #{p}" break end end end end end } -- Posted via http://www.ruby-forum.com/.