Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 811a77189b58c9aa7d4b5fdb0255a67afc2c006b 0 parents
@elefevre authored
Showing with 44 additions and 0 deletions.
  1. +29 −0 basic.ik
  2. +6 −0 fibonacci.ik
  3. +9 −0 fizzbuzz.ik
29 basic.ik
@@ -0,0 +1,29 @@
+;; appel de la méthode println sur un objet de type Text
+"Hello" println
+
+;; 2 appels sur la même ligne
+"hello" println. "world" println.
+
+;; création d'une méthode
+foo = method("Hello" println)
+foo()
+
+;; une méthode est un objet de type "DefaultMethod"
+method() kind println
+
+;; calcul du factoriel du nombre 10
+fact = method(n, if((0..1) include?(n), 1, n * fact(n-1)))
+fact(10) println
+
+;; création d'un nouveau type
+Foo = Origin mimic
+Foo kind println
+
+;; création d'une instance
+foo = Foo mimic
+foo kind println
+
+;; obtenir des singletons en surchargeant la méthode de sous-typage
+Foo = Origin mimic
+Foo mimic = Foo
+if(Foo == Foo mimic, "Foo is a singleton", "Foo is a normal type") println
6 fibonacci.ik
@@ -0,0 +1,6 @@
+;; Fibonacci de 1 à 15
+fibonacci = method(number,
+ if((0..1) include?(number), 1, fibonacci(number - 1) + fibonacci(number - 2))
+)
+
+(1..15) map(n, fibonacci(n)) join("\n") println
9 fizzbuzz.ik
@@ -0,0 +1,9 @@
+;; FizzBuzz de 1 à 23
+
+fizzBuzz = method(number,
+ result = [3, 5] map(n, if(number % n == 0, {3 => "Fizz", 5 => "Buzz"}[n], "")) join
+
+ if(result empty?, number asText, result)
+)
+
+(1..23) map(n, fizzBuzz(n)) join("\n") println
Please sign in to comment.
Something went wrong with that request. Please try again.