Giter Club home page Giter Club logo

Comments (7)

ceddlyburge avatar ceddlyburge commented on June 23, 2024 1

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

from elm.

ceddlyburge avatar ceddlyburge commented on June 23, 2024

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 [...]"?

from elm.

alvaro121 avatar alvaro121 commented on June 23, 2024

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

from elm.

ceddlyburge avatar ceddlyburge commented on June 23, 2024

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.

from elm.

alvaro121 avatar alvaro121 commented on June 23, 2024

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.

from elm.

ceddlyburge avatar ceddlyburge commented on June 23, 2024

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

from elm.

alvaro121 avatar alvaro121 commented on June 23, 2024

Go ahead with the changes.

from elm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.