RosettaCodeData/Task/First-class-functions/Deja-Vu/first-class-functions.djv

19 lines
274 B
Text
Raw Permalink Normal View History

2013-10-27 22:24:23 +00:00
negate:
- 0
2014-01-17 05:32:22 +00:00
set :A [ @++ $ @negate @-- ]
2013-10-27 22:24:23 +00:00
2014-01-17 05:32:22 +00:00
set :B [ @-- $ @++ @negate ]
2013-10-27 22:24:23 +00:00
test n:
for i range 0 -- len A:
2014-01-17 05:32:22 +00:00
if /= n call compose @B! i @A! i n:
2013-10-27 22:24:23 +00:00
return false
true
2014-01-17 05:32:22 +00:00
test to-num !prompt "Enter a number: "
2013-10-27 22:24:23 +00:00
if:
2014-01-17 05:32:22 +00:00
!print "f^-1(f(x)) = x"
2013-10-27 22:24:23 +00:00
else:
2014-01-17 05:32:22 +00:00
!print "Something went wrong."