Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Created January 28, 2018 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/8391d05b3c7a7e4669fbe4840c2bc6ca to your computer and use it in GitHub Desktop.
Save zoffixznet/8391d05b3c7a7e4669fbe4840c2bc6ca to your computer and use it in GitHub Desktop.
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