Skip to content
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

Wording on Luigi's luscious lasagna #492

Closed
alvaro121 opened this issue Jun 14, 2022 · 7 comments
Closed

Wording on Luigi's luscious lasagna #492

alvaro121 opened this issue Jun 14, 2022 · 7 comments

Comments

@alvaro121
Copy link

Hello,
At Luigi's luscious lasagna's problem description it says (bolded by me)

Define the preparationTimeInMinutes constant (in the let part of the let expression) that takes the number of layers you added to the lasagna as a parameter and [...]

The example shows that it should actually be a function, so I think saying to define it as a constant (a constant function?) is confusing. I have seen some community solutions and they seem to be split at defining it as a constant or a function.

Likewise, it says

Define the remainingTimeInMinutes function (in the in part of the let expression) that takes two parameters [...]

But I don't think you can define the function in the in part of the let expression, but instead the function's body is a let expression whose in part is the final calculation.

@ceddlyburge
Copy link
Contributor

Hi there. This is a good point, we will have a think.

The Elm syntax itself doesn't include constants, but people often call functions with zero parameters 'constants' (especially ones where the return value is just a single value, like in expectedMinutesInOven), which is why it gets confusing I think. Maybe we should just call them all functions.

I think the second point is a bit easier, maybe "Define the remainingTimeInMinutes calculation (in the in part of the let expression) that takes two parameters [...]"?

@alvaro121
Copy link
Author

people often call functions with zero parameters 'constants'

I didn't knew that constants were actually functions with zero parameters, I thought all functions took exactly one parameter.

Regardless, the example shows preparationTimeInMinutes taking an argument (as is implied by "that takes the number of layers you added to the lasagna as a parameter")

preparationTimeInMinutes 3
--> 6

So it wouldn't be a constant either.

maybe "Define the remainingTimeInMinutes calculation (in the in part of the let expression) that takes two parameters [...]"?

That would seem to imply that the calculation takes two parameters. Maybe just say that remainingTimeInMinutes should be a function of two parameters and its body a let expression where expectedMinutesInOven and preparationTimeInMinutes are locally defined (which I think is the intended solution).

@ceddlyburge
Copy link
Contributor

How about something like this?

Define the remainingTimeInMinutes function that takes two parameters and has a let expression as its body. The first parameter is the number of layers you added to the lasagna, and the second parameter is the number of minutes since you starting cooking.

Define expectedMinutesInOven (in the let part of the let expression) to check how many minutes the lasagna should be in the oven. According to the cooking book, the expected oven time in minutes is 40:

...

Define preparationTimeInMinutes (in the let part of the let expression) that takes the number of layers you added to the lasagna as a parameter and returns how many minutes you spent preparing the lasagna, assuming each layer takes you 2 minutes to prepare.

...

Return how many minutes are left until the lasagna is finished (in the in part of the let expression), which is the sum of the preparationTimeInMinutes and the expectedMinutesInOven minus the number of minutes since you starting cooking.

@alvaro121
Copy link
Author

That looks good.

As minor details,

It says "Define expectedMinutesInOven to check how many minutes the lasagna should be in the oven." but expectedMinutesInOven does not check the minutes the lasagna should be in the oven, but is the amount of minutes itself (the example makes it clear that it should be a constant, so there shouldn't be any confusion anyhow).

Throughout the problem it says "the number of layers you added", but, in fact, some layers may not have been added yet which is why you add the preparation time to the remaining time (if they were already added, they would not be remaining).

Also, I noticed the dict's concept it says

A list of key value pairs can be converted into a list with fromList.

alice = Dict.fromList [ ( 0, "Bob" ), ( 0, "Alice" ) ]
--> True Dict.fromList [ ( 0, "Alice" ) ]

It probably means "into a dict".

Could you point to some reference where functions with zero parameters are explained?
I checked https://elm-lang.org/docs/syntax but it doesn't seem to be comprehensive.

Thanks.

@alvaro121 alvaro121 reopened this Jun 14, 2022
@ceddlyburge
Copy link
Contributor

ceddlyburge commented Jun 15, 2022

Hi There, I'm not sure the const / function thing is explained anywhere. The fact that functions have no brackets mean that a constant and a zero parameter function are defined using the same syntax, and retrieved using the same syntax. This along with the fact that all functions are pure and all values are immutable means that there is no practical or logical difference between the two things. So it doesn't really matter what it is called I suppose.

I'll make these changes, and updated the dict concept, unless you would like to?

Cheers, Cedd

@alvaro121
Copy link
Author

Go ahead with the changes.

ceddlyburge added a commit that referenced this issue Jun 16, 2022
@ceddlyburge
Copy link
Contributor

I've made those changes, do you want to review the pull request above (#493)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants