Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,3 @@
(defrecord complex
real
img)

View file

@ -0,0 +1,17 @@
(defun add
(((match-complex real r1 img i1)
(match-complex real r2 img i2))
(new (+ r1 r2) (+ i1 i2))))
(defun mult
(((match-complex real r1 img i1)
(match-complex real r2 img i2))
(new (- (* r1 r2) (* i1 i2))
(+ (* r1 i2) (* r2 i1)))))
(defun neg
(((match-complex real r img i))
(new (* -1 r) (* -1 i))))
(defun inv (cmplx)
(div (conj cmplx) (modulus cmplx)))

View file

@ -0,0 +1,3 @@
(defun conj
(((match-complex real r img i))
(new r (* -1 i))))

View file

@ -0,0 +1,11 @@
(defun new (r i)
(make-complex real r img i))
(defun modulus (cmplx)
(mult cmplx (conj cmplx)))
(defun div (c1 c2)
(let* ((denom (complex-real (modulus c2)))
(c3 (mult c1 (conj c2))))
(new (/ (complex-real c3) denom)
(/ (complex-img c3) denom)))))

View file

@ -0,0 +1,11 @@
(defun ->str
(((match-complex real r img i)) (when (>= i 0))
(->str r i "+"))
(((match-complex real r img i))
(->str r i "")))
(defun ->str (r i pos)
(io_lib:format "~p ~s~pi" `(,r ,pos ,i)))
(defun print (cmplx)
(io:format (++ (->str cmplx) "~n")))