-
-
Notifications
You must be signed in to change notification settings - Fork 360
Added Euclidean Algorithm for lisp #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Euclidean Algorithm for lisp #349
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- If you give
euclid-sub
any negative arguments, it will overflow. You'll need to callabs
on both of them. euclid-mod
doesn't overflow, but can return a negative number. I think(if (zerop b))
,(abs a)
.
@@ -0,0 +1,18 @@ | |||
;;;;Bubble sort implementation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You added this file by accident.
@@ -0,0 +1,15 @@ | |||
(defun euclid_sub (a b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming convention is to use kebab-case (https://en.wikipedia.org/wiki/Naming_convention_(programming)#Lisp), so replace the underscores with dashes.
|
||
;; built-in funciton: (gcd 80 40) | ||
(print (euclid_sub 24 27)) ;should output 3 | ||
(print (euclid_mod 90 27)) ;should output 9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use the same example as the Clojure file:
(print
(euclid-sub (* 64 67)
(* 64 81)))
(print
(euclid-mod (* 128 12)
(* 128 77)))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super minor: the comment misspells "funciton"
a | ||
(euclid_mod b (mod a b)))) | ||
|
||
;; built-in funciton: (gcd 80 40) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
funciton -> function
- I would actually execute this code. Even better, you can compare against your implementation:
(assert (= (euclid-sub (* 64 67) (* 64 81))
(gcd (* 64 67) (* 64 81))))
CONTRIBUTORS.md
Outdated
@@ -57,3 +57,5 @@ NIFR91 | |||
Michal Hanajik | |||
<br> | |||
Bendik Samseth | |||
Trashtalk | |||
Trashtalk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you've already done this as part of #348, you'll need to undo these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you
No description provided.