sharkdp / numbat

A statically typed programming language for scientific computations with first class support for physical dimensions and units
https://numbat.dev
Apache License 2.0
1.26k stars 53 forks source link

Cannot find quadratic_equation on numbat.dev #602

Closed deepakjois closed 1 month ago

deepakjois commented 1 month ago
image
sharkdp commented 1 month ago

You need to import extra::algebra to use this function (https://numbat.dev/doc/list-functions-math.html?highlight=quadra#algebra)

use extra::algebra
deepakjois commented 1 month ago

Thanks! I suspected I wasnt importing something. But I couldnt find the use keyword anywhere even after skimming the docs multiple times. Maybe worth putting this info somewhere in the docs where it can be found easily?

deepakjois commented 1 month ago

This place may be a bit too obscure, and i initially thought it might be for custom modules that we write and not for modules that are available by default

Goju-Ryu commented 1 month ago

It might be a good idea in general to explicitly tell if a module is auto imported or if you should use it first. I imagine a single line under the

Defined in: extra::algebra

Maybe something like:

requires using: use extra::algebra

It would require some changes to the build script in book, but I wouldn't mind taking a stab at it if @sharkdp agrees that something like this would be beneficial.

Edit: after taking a look at the documentation I noticed that some of the module lines lists multiple modules. It should still be possible to implement, but some thought should be put into how it is formatted in those cases.

Goju-Ryu commented 1 month ago

An alternative approach I just thought of that would be much easier is to just change the sidebar so that it contains prelude modules as a subcategory of The prelude and all other predefined functions stay as a subcategory of Predefined functions, which then just gets a bit descriptive text about how to use the modules found there. It's much easier, probably more intuitive and would avoid repeating basically the same line everywhere.

sharkdp commented 1 month ago

This place may be a bit too obscure, and i initially thought it might be for custom modules that we write and not for modules that are available by default

True. Let's improve this.

requires using: use extra::algebra

I have another idea. Since #566 has been merged, we now have example code for every function Numbat. See https://numbat.dev/doc/list-functions-math.html?highlight=quadra#quadratic_equation-solve-quadratic-equations, for example. Maybe we should add use extra::algebra as an additional line to the examples that require it? We already add the use extra::algebra line when you click on the "Run this code" button. FYI: @Bzero

Goju-Ryu commented 1 month ago

Maybe we should add use extra::algebra as an additional line to the examples that require it?

I like that way of doing it. It keeps it close to the function and makes it obvious how the example was able to call the it.

Bzero commented 1 month ago

I have another idea. Since #566 has been merged, we now have example code for every function Numbat. See https://numbat.dev/doc/list-functions-math.html?highlight=quadra#quadratic_equation-solve-quadratic-equations, for example. Maybe we should add use extra::algebra as an additional line to the examples that require it? We already add the use extra::algebra line when you click on the "Run this code" button. FYI: @Bzero

That should be quite easy to do, the necessary use statements are already there, they just don't get printed. I didn't add them to the examples to keep them concise but I agree that it would make it more obvious how to use non-prelude functions.