S
S
Sasha_882019-04-17 20:44:11
Haskell
Sasha_88, 2019-04-17 20:44:11

Is it possible to set a system of equations in Haskell so that he solves it himself? Instead of writing functions for the solution yourself?

For example, there is a system of equations 5cb76300d4c00212311445.jpeg
. Do you need to write the solution yourself in a functional language? Functional style is declarative, like prologue? And then simply in the definition of declarative it says write what you need to get and you will get a solution. The system will find it on its own. But it seems like functional languages ​​(compilers) do not give this goodie. As I understand it, functional languages ​​are just functional. Functions, purity are all there, but you have to write all the code for the solution yourself, just like in imperative programming. So right?
Thank you.
Sasha

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Skusnov, 2019-04-18
@AlexSku

I don't know the prologue, but the functional style is really declarative. Eg. x = x +1 in imperative means to add the value of x to one and put the result in x.
In FP, this would be a recursive call to x.
About the solution. For example, in Matlab this system is written as A*x = b, where A is a 2x2 matrix, x is a 2x1 vector of unknowns (x and y), and b is a 2x1 vector of the left side. The solution is in the form of left division: x = A \ b.
In Haskell, it would be necessary to describe the data type "matrix" and the operator "left division" (you can use the triangle method) and then - voila, everything will work out.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question