-
-
Save zoffixznet/8391d05b3c7a7e4669fbe4840c2bc6ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use nqp; | |
nqp::stmts( | |
nqp::srand(nqp::time_i), | |
nqp::if( | |
nqp::isgt_n(nqp::rand_n(1e0), .5e0), | |
nqp::say('Glass half full'), | |
nqp::say('Glass half empty'))); | |
use QAST:from<NQP>; | |
BEGIN $*W.compile_time_evaluate: $, | |
QAST::Op.new(:op('if'), | |
QAST::Op.new(:op('isgt_n'), | |
QAST::Op.new(:op('rand_n'), | |
QAST::SVal.new(:value(1e0)) | |
), | |
QAST::SVal.new(:value(.5e0)) | |
), | |
QAST::Op.new(:op('say'), | |
QAST::SVal.new(:value('Glass half full')) | |
), | |
QAST::Op.new(:op('say'), | |
QAST::SVal.new(:value('Glass half full')) | |
) | |
); | |
use QAST:from<NQP>; | |
BEGIN $*W.compile_time_evaluate: $, | |
QAST::Op.new: :op<if>, | |
QAST::Op.new(:op<isgt_n>, | |
QAST::Op.new(:op<rand_n>, | |
QAST::SVal.new: :value(1e0)), | |
QAST::SVal.new: :value(.5e0)), | |
QAST::Op.new(:op<say>, | |
QAST::SVal.new: :value('Glass half full')), | |
QAST::Op.new: :op<say>, | |
QAST::SVal.new: :value('Glass half full') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment