Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Arithmetic-Complex/LFE/arithmetic-complex-1.lfe
Normal file
3
Task/Arithmetic-Complex/LFE/arithmetic-complex-1.lfe
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(defrecord complex
|
||||
real
|
||||
img)
|
||||
17
Task/Arithmetic-Complex/LFE/arithmetic-complex-2.lfe
Normal file
17
Task/Arithmetic-Complex/LFE/arithmetic-complex-2.lfe
Normal 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)))
|
||||
3
Task/Arithmetic-Complex/LFE/arithmetic-complex-3.lfe
Normal file
3
Task/Arithmetic-Complex/LFE/arithmetic-complex-3.lfe
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(defun conj
|
||||
(((match-complex real r img i))
|
||||
(new r (* -1 i))))
|
||||
11
Task/Arithmetic-Complex/LFE/arithmetic-complex-4.lfe
Normal file
11
Task/Arithmetic-Complex/LFE/arithmetic-complex-4.lfe
Normal 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)))))
|
||||
11
Task/Arithmetic-Complex/LFE/arithmetic-complex-5.lfe
Normal file
11
Task/Arithmetic-Complex/LFE/arithmetic-complex-5.lfe
Normal 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")))
|
||||
Loading…
Add table
Add a link
Reference in a new issue