From 3206d602859f5572b958fcc36ba56c9596ecb292 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 25 Aug 2008 18:49:42 +0000 Subject: butwis --- examples/bitwise.fy | 32 ++++++++++++++++++++++++++++++++ examples/broken/bitwise.fy | 32 -------------------------------- 2 files changed, 32 insertions(+), 32 deletions(-) create mode 100644 examples/bitwise.fy delete mode 100644 examples/broken/bitwise.fy (limited to 'examples') diff --git a/examples/bitwise.fy b/examples/bitwise.fy new file mode 100644 index 0000000..03fda6c --- /dev/null +++ b/examples/bitwise.fy @@ -0,0 +1,32 @@ +#* + * Examples of how to use bitwise operators + *# + +# Prints "01\n" +assert 0 == (put 1 and 0); +assert 1 == (say 1 and 1); + +# Prints "01\n" +assert 0 == (put 0 or 0); +assert 1 == (say 0 or 1); + +# Prints "01\n" +assert 0 == (put 1 xor 1); +assert 1 == (say 1 xor 0); + +# Prints "82\n" +assert 8 == (put 2 :< 2); +assert 2 == (say 8 :> 2); + +# A bit more complex, prints "9\n" +assert 9 == (say 1 :< 5 :> 5 or 2 and 5 xor 8); + +# Same result, but with parenthesis: +assert 9 == (say ((((1 :< 5) :> 5) or 2) and 5) xor 8); + +# Different parenthesis, different result: "1\n" +assert 1 == (say 1 :< 5 :> 5 or 2 and (5 xor 8)); + +# Prints "-1" +assert (neg 1) == (say neg not 0); + diff --git a/examples/broken/bitwise.fy b/examples/broken/bitwise.fy deleted file mode 100644 index 03fda6c..0000000 --- a/examples/broken/bitwise.fy +++ /dev/null @@ -1,32 +0,0 @@ -#* - * Examples of how to use bitwise operators - *# - -# Prints "01\n" -assert 0 == (put 1 and 0); -assert 1 == (say 1 and 1); - -# Prints "01\n" -assert 0 == (put 0 or 0); -assert 1 == (say 0 or 1); - -# Prints "01\n" -assert 0 == (put 1 xor 1); -assert 1 == (say 1 xor 0); - -# Prints "82\n" -assert 8 == (put 2 :< 2); -assert 2 == (say 8 :> 2); - -# A bit more complex, prints "9\n" -assert 9 == (say 1 :< 5 :> 5 or 2 and 5 xor 8); - -# Same result, but with parenthesis: -assert 9 == (say ((((1 :< 5) :> 5) or 2) and 5) xor 8); - -# Different parenthesis, different result: "1\n" -assert 1 == (say 1 :< 5 :> 5 or 2 and (5 xor 8)); - -# Prints "-1" -assert (neg 1) == (say neg not 0); - -- cgit v1.2.3