File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -56,10 +56,11 @@ curlies `puts fruit{'bananas'}`
56
56
57
57
nqp op-codes can be called like regular functions. E.g.
58
58
```
59
- puts nqp::sprintf("pid=%s time=%d", [nqp::getpid, nqp::time_i])'
60
59
puts nqp::if(2+2 == 4, 'yup', 'nope' )
60
+ def sprintf(fmt, *args) ; nqp::sprintf(fmt, args) ; end
61
+ puts sprintf("pid=%s time=%d", nqp::getpid, nqp::time_i)
61
62
```
62
- - this includes nqp control-flow functions:
63
+ this includes nqp control-flow functions:
63
64
```
64
65
n = 99
65
66
nqp::while n > 0, begin
Original file line number Diff line number Diff line change 2
2
3
3
LIMIT = 50000
4
4
def time ( ) ; nqp ::time_n ( ) ; end
5
+ def sprintf ( fmt , *args ) ; nqp ::sprintf ( fmt , args ) ; end
5
6
6
7
pi_over_4 = 0.0
7
8
@@ -17,8 +18,8 @@ while n > 0 do
17
18
n -= 1
18
19
end
19
20
20
- puts nqp :: sprintf ( "(completed %d iterations in %.2f sec)" ,
21
- [ LIMIT , time ( ) - start_time ] )
21
+ puts sprintf ( "(completed %d iterations in %.2f sec)" ,
22
+ LIMIT , time ( ) - start_time )
22
23
23
24
pi = pi_over_4 * 4
24
25
puts pi
You can’t perform that action at this time.
0 commit comments