-
Notifications
You must be signed in to change notification settings - Fork 3
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
Naming conventions #16
Comments
We can create |
|
I am not in the target demography, but I really dislike the |
Agreed on |
For last we can just use |
OK, since nobody else has commented, let's use I'm fine with Are |
D'oh... Clojure's |
I think that Also need to add that the code needs to have spaces instead of tabs it may look nice in one editor but be broken on the website or in another editor. One person added a code snippet with tabs and looked like broken indentation but he only use 4 stops in the editor and I think that the browser uses 8, because replacing the tabs with 4 space fixed the indentation issue, |
The idea is that looping and recursion are different things; looping is O(1) tail recursion, general recursion is O(n). But Clojure has made this confusion because its
Works for me. Or name them according to what they do.
Agreed.
Agreed. It makes no sense to use tabs in Lisp code, since the 2-space indent is universally accepted. |
- The (if (null? result) ...) check can be done once, before the loop. It doesn't need to be done separately on each iteration. - Carrying the result as a string, and using string-append on each iteration, is probably more efficient than gathering the strings into a temporary list. Avoiding apply will also avoid implementation limits on how many args can be passed to a procedure (if list is very long, it can exceed the limit). - Use the names `lst` and `loop` as decided in #16.
- The (if (null? result) ...) check can be done once, before the loop. It doesn't need to be done separately on each iteration. - Carrying the result as a string, and using string-append on each iteration, is probably more efficient than gathering the strings into a temporary list. Avoiding apply will also avoid implementation limits on how many args can be passed to a procedure (if list is very long, it can exceed the limit). - Use the names `lst` and `loop` as decided in #16.
We should probably decide on common names to use for variables in similar situations. For example:
list
argument to procedure (orlis
orlst
) by default?(let ((elem (car list)) (rest (cdr list))) ...)
(let loop ...)
?inner
andouter
with nested loops.loop
andrecurse
are good ways to differentiate proper tail recursion (needs O(1) stack space) from general recursion (O(n) stack space).Haskell has a convention of using
x
for a list element, andxs
for the list.xs
is meant as the plural ofx
: "multiple x's". They also usey
andys
.The text was updated successfully, but these errors were encountered: