-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Hello World exercise not trivial in scheme #34
Comments
Is there a way to change the exercise to make it trivial? We can always make the README more ambiguous to suit. |
We could either add an explanation that optional arguments are explained in the links above. I think the optional argument exercise is a valuable exercise. If we feel that even with an explanation it is too much for the initial hello world exercise and would be more suited to a later problem we could ask for two functions to be defined.
|
@kytrinyx The issue is Scheme's treatment of variadic functions, so the easiest change for Scheme would be to make it either arity-0 ("Hello, world!" only) or arity-1 ("Hello, {{arg}}!" only) and not have an optional argument to the function. Now, as @PurityControl pointed out, there are multiple ways to do variadic functions in Scheme, some specified in R5RS or R6RS, and some implementation-specific; I think it makes Scheme a really interesting track from a high level perspective just to see what people come up with, but for "hello world"... IIRC, Abelson and Sussman don't even throw variadic functions at you until halfway through SICP. I'm open to any changes that seem sensible to everyone, whether that's making the README more vague to allow for wider types of implementation, or putting some more structure in Okay, maybe not that last one. |
That totally made me smirk, but yah, maybe not :) |
Here's a possibility: Include in the stub: (define hello
(λ (name)
(string-concatenate (list "Hello, " name "!")))) Include a (already passing) test for that, leaving it to the user to implement: (define hello-world
(λ ()
(hello "World"))) To get the other test to pass. I'm thinking this b/c the point (unless I'm mistaken) is "How do I exercism?" more than "How do I scheme?". The drawback IMHO is that it is non-standard in providing an implementation file with working code in it. But maybe that could be explained in the comments. Thoughts? |
Seems like a pragmatic solution to me. |
I think it's completely fine to provide an implementation file with working code... it's not a complete solution after all. |
Given the purpose of the hello world exercise, the solution in scheme maybe harder than we would like.
The r5rs specification gives a portable implementation for optional arguments. However use of this, as I understand it, requires knowledge of setting up functions with the more formal definition of a function using lambda and making the arguments to lambda a symbol rather than a list.
That is the traditional
will no longer work and requires
this is non intuitive as the lambda form is normally
Guile offers a non portable
define*
which is slightly less confusing but requires users to be familiar with guile's library.I think it may be worth adding further information to the README with a small explanation and links
to further reference such as
https://www.gnu.org/software/guile/manual/html_node/Optional-Arguments.html
https://www.gnu.org/software/guile/manual/html_node/Lambda.html#Lambda
https://www.gnu.org/software/guile/manual/html_node/lambda_002a-and-define_002a.html#lambda_002a-and-define_002a
The text was updated successfully, but these errors were encountered: