Skip to content

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

Merged
merged 1 commit into from
Aug 14, 2018
Merged

Added Euclidean Algorithm for lisp #349

merged 1 commit into from
Aug 14, 2018

Conversation

Trashtalk217
Copy link
Contributor

No description provided.

@Gathros Gathros added the Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) label Aug 9, 2018
Copy link
Member

@berquist berquist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. If you give euclid-sub any negative arguments, it will overflow. You'll need to call abs on both of them.
  2. 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
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

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)))

Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. funciton -> function
  2. 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
Copy link
Member

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.

Copy link
Member

@jiegillet jiegillet left a 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

@jiegillet jiegillet merged commit cf487dd into algorithm-archivists:master Aug 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants