-
- Notifications
You must be signed in to change notification settings - Fork 359
Lisp jarvis march #446
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
Lisp jarvis march #446
Conversation
This reverts commit ba85d61. modified: CONTRIBUTORS.md
List of things I'm still not happy with:
The reason why I removed the WIP label, is because I want additional input, besides my own. I expect that there'll be more people looking to review, when it doesn't have this label. |
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.
Just some small things I noticed
I've tried, but I don't know how to shorten the functions involved in calculating the angle. My linear algebra is a bit rusty and the way others do it looks (and maybe is) quite different. If anyone can elaborate that would be very much appreciated. |
…rithm-archive into lisp-jarvis-march
I've fixed all the things I was unhappy with. All I need now is a review! |
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.
It looks good, I can understand everything fairly well. I am not a fan of loops and I'm sure there are things that could be refined but it would probably be matter of taste at that point.
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.
Let me know if I missed something.
(if (< (point-x p1) (point-x p2)) p1 p2)) | ||
gift)) | ||
| ||
(defun second-point-on-hull (start gift) |
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 think I realized you don't need second-point-on-hull
. Alls it does is call next-point-on-hull
you might as well do that in your loop.
You can start your hull with the (- (point-y start) 1)
and start
points. And then remove the fake point later.
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.
Are you sure this is a good idea, because the the first element of the hull, as defined in the hull list, will then become the starting point, so the check after that until (equalp (first hull) start)
will pass and the loop will end, I cannot find an elegant way around that, do you have an idea?
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 could place an extra check like if length hull is greater then 2
, that might work.
Honestly don't know if this is an improvement, but it's a couple lines less once more. |
I think it's an improvement, removing one function help reading the code. I apologize if my ideal piece of code is the shortest that can be. Feel free to fight back especially since I don't actually know lisp. |
I wouldn't have expected anything else from a haskell programmer, @jiegillet. But, jokes aside, I mostly agree with you. There's something very satisfying about getting your code under 100 lines and if you're not cramping everything together it more often then not makes it more readable. I, however, do not understand what you mean in you're request. Could you please be a little more clear? |
Something like: (loop with start = (leftmost-point gift) with hull = (list start (make-point (point-x start) (- (point-y start) 1))) do (setq hull (cons (next-point-on-hull (first hull) (second hull) gift) hull)) while (/= (first hull) start) (although I'm pretty sure my syntax is wrong at more than one place) |
I actually can't believe it worked, but it did. |
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 must be a Lisp genius! Imagine if I actually learned it ;)
One last copy/paste incident to fix and we're good to go
[import, lang:"c_cpp"](code/c++/jarvis_march.cpp) | ||
{% sample lang="lisp" %} | ||
[import, lang:"lisp"](code/lisp/jarvis-march.lisp) | ||
{% sample lang="lisp" %} |
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 imported it twice!
It's finally done I think, thanks for reviewing @jiegillet and @c252 |
It works, but that is mostly all that can be said about it. I am nowhere near happy with it, but I want people to review it and give some tips. That's also the reason I haven't editted the .md files for Jarvis March. I'll be working on it way more, but for now you can enjoy the spaghetti.