From 88bcec774b782319aa4ce32a39c101568d01925a Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 16 Oct 2016 21:46:51 +0200 Subject: examples --- examples/hamming.fusp | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 examples/hamming.fusp (limited to 'examples/hamming.fusp') diff --git a/examples/hamming.fusp b/examples/hamming.fusp new file mode 100644 index 0000000..9c6aa48 --- /dev/null +++ b/examples/hamming.fusp @@ -0,0 +1,12 @@ +import list; +import int; +import bool; + +// Taken from the Clean examples: the Hamming function. +// The first 100 numbers with only 2, 3 and 5 as prime factors. + +ham = [1:merge (merge (map (mul 2) ham) (map (mul 3) ham)) (map (mul 5) ham)]; + +merge [a:b] [c:d] = if (lt a c) [a:merge b [c:d]] (if (eq a c) (merge [a:b] d) [c:merge [a:b] d]); + +main = take 100 ham; -- cgit v1.2.3