ZyK_BotaN wrote:

it is passed...
Well the last line that was possible and so to write:

``norm v = prod v \$1.0 / sqrt \$ sprod v v;``

. Two questions. Well. To me priorities with brackets are customarier.  I made 2 steps
Back and nevertheless wrote down so.

``norm v = prod v (1.0 / sqrt (sprod v v));``

It is norms from the point of view of Haskell? Well  I hope that I terrible did not lose anything from
Such conversion.
And the second question. The designer of type. How I can normalize a vector (3.0, 4.0, 5.0)?
I declared function norm as

``norm:: Vector-&gt; Vector``

And that substitution worked I should inform somehow on that that it not simply tuple namely the Vector.

ZyK_BotaN wrote:

it is passed...
What for in brackets took argument?

Well . Took and took. Like broke nothing. Simply () for the present not  to the list
To the description of arguments.

mayton wrote:

Well. To me priorities with brackets are customarier.

mayton wrote:

It is norms from the point of view of Haskell?

It not . Here do not approve, but it is tolerant quite.

mayton wrote:

and that substitution worked I should inform somehow on that that it not simply tuple namely the Vector.

Should not. Here Vector - a synonym  from 3 .
If you want separate type make either newtype or data.
When alternative  is not present, it is better newtype

ZyK_BotaN wrote:

should not. Here Vector - a synonym  from 3 .
If you want separate type make either newtype or data.
When alternative  is not present, it is better newtype

And on performance there are any recommendations?

mayton wrote:

it is passed...
And on performance there are any recommendations?

Differences should not be.
But if you want that  with vectors  differed, here so write:

``````newtype Vector = Vector (Double, Double, Double)
summation:: Vector-&gt; Vector-&gt; Vector
summation (Vector (x1, y1, z1)) (Vector (x2, y2, z2)) = Vector (x1 + x2, y1 + y2, z1 + z2)``````

ZyK_BotaN,  start up there will be an old variant without explicit instructions of vectors. Then
I will compare when there will be all code is written.

mayton wrote:

Then
I will compare when there will be all code is written.

In speed - differences will not be. It for .

mayton wrote:

And on performance there are any recommendations?

On  the heat when calculations you will start to write begins.  here prepares surprises (:

.  operations with algebra of vectors. There is certainly and other actions
For example checks of conditions and parameter passing in a recursion and cleaning
(Here was a procorf at Java) but the main trunk  lies only on
Calculations Double.

mayton wrote:

Nutyvidel.  operations with algebra of vectors. There is certainly and other actions
For example checks of conditions and parameter passing in a recursion and cleaning
(Here was a procorf at Java) but the main trunk  lies only on
Calculations Double.

gives surprises for the beginner, in respect of implementation of "cycles"

ZyK_BotaN wrote:

it is passed...
gives surprises for the beginner, in respect of implementation of "cycles"

Yes I already . But I hope bypass of Cartesian coordinates represents
The solved task.  there or Stepanovsky tail or  recursions.
Yes... I started to collect all source code. While .

``````import Text. Printf
width = 512
height = 512
g = [0x0003C712;
0x00044814;
0x00044818;
0x0003CF94;
0x00004892;
0x00004891;
0x00038710;
0x00000010;
0x00000010]
type Vector = (Double, Double, Double)
sum:: Vector-&gt; Vector-&gt; Vector
sum (x1, y1, z1) (x2, y2, z2) = (x1 + x2, y1 + y2, z1 + z2)
prod:: Vector-&gt; Double-&gt; Vector
prod (x, y, z) (r) = (r * x, r * y, r * z)
sprod:: Vector-&gt; Vector-&gt; Double
sprod (x1, y1, z1) (x2, y2, z2) = x1 * x2 + y1 * y2 + z1 * z2
norm:: Vector-&gt; Vector
==&gt; norm (x, y, z) = prod (x, y, z) (1.0 / sqrt (sprod ((x, y, z) (x, y, z))));``````

I smoke. A dog .

``````card.hs:38:54: error:
* Couldn't match expected type ` (Double, Double, Double)-&gt; Vector'
with actual type ` (Double, Double, Double)'
* The function ` (x, y, z) ' is applied to one argument;
but its type ` (Double, Double, Double) ' has none
In the first argument of ` sprod ', namely ` ((x, y, z) (x, y, z))'
In the first argument of ` sqrt ', namely
` (sprod ((x, y, z) (x, y, z)))'
|
38 | norm (x, y, z) = prod (x, y, z) (1.0 / sqrt (sprod ((x, y, z) (x, y, z))));
| ^^^^^^^^^^^^^^^^^^^``````

mayton wrote:

Tsykl there or Stepanovsky tail or  recursions.

By default, in  it is not necessary to write tail, after all it lazy.
But is  cases, when laziness only to the detriment then it is written explicitly "vigorous" . It it is already possible also tail.
For on the beginnings, we try normal, and further  it is measured.

mayton wrote:

I Smoke. A dog .

It is impossible  after sprod to write, one argument, instead of two turns out that at you

ZyK_BotaN wrote:

it is passed...
It is impossible  after sprod to write, one argument, instead of two

turns out that at you
Replace on

``norm (x, y, z) = prod (x, y, z) (1.0 / (sqrt (sprod (x, y, z) (x, y, z))))``

.. And why you did not refuse from  on  a vector if you them are explicit not .
Why not?

``norm v = prod v (1.0 / (sqrt (sprod v v)))``

ZyK_BotaN wrote:

it is passed...
It is impossible  after sprod to write, one argument, instead of two

turns out that at you
I.e. in  function invocation registers not:

``f (x y)``

And:

``(f x y)``

ZyK_BotaN wrote:

.. And why you did not refuse from  on  a vector if you them are explicit not .
Why not?

. . . GHCI told APPRX.
A bit later there will be a question on printf, IO.

I/O, something is time to me  on stdout.
I feel that I  will climb in any jungle. The output order there. Absence side-effect e.t.c. But to me it is necessary
This mechanism in any type to solve the task.

``````import System. IO
import Text. Printf
--putStr ("Hello")
putStrLn ("Hello" ++ width)``````
``````Prelude&gt;:l card.hs
[1 of 1] Compiling Main (card.hs, interpreted)
card.hs:42:1: error:
Parse error: module header, import declaration
or top-level declaration expected.
|
42 | putStrLn ("Hello" ++ width)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

mayton wrote:

I/O, something is time to me  on stdout.

main:: IO ()
main = do c &lt;- getChar
putChar c

The use of the name main is important : main is defined to be the entry point of a Haskell program (similar to the main function in A C), and must have an IO type, usually IO (). (The name main is special only in the module Main; we will have more to say about modules later.) This program performs two actions in sequence: first it reads in a character, binding the result to the variable c, and then prints the character. Unlike a let expression where variables are scoped over all definitions, the variables defined by &lt;- are only in scope in the following statements.

WebSharper wrote:

The use of the name main is important :

So you understood, what it is necessary in  to "fulfill" functions with ?

mayton wrote:

``````import System. IO
import Text. Printf``````

What for to you this import? What therefrom functions you use?

ZyK_BotaN wrote:

it is passed...
What for to you this import? What therefrom functions you use?

It is casual noise which remained from samples. Tried putStr, printf.

WebSharper wrote:

it is passed...
main:: IO ()
main = do c &lt;- getChar
putChar c

The use of the name main is important : main is defined to be the entry point of a Haskell program (similar to the main function in A C), and must have an IO type, usually IO (). (The name main is special only in the module Main; we will have more to say about modules later.) This program performs two actions in sequence: first it reads in a character, binding the result to the variable c, and then prints the character. Unlike a let expression where variables are scoped over all definitions, the variables defined by &lt;- are only in scope in the following statements.

And it is possible somehow  these  for the theory? I after all need to arrange
Some calls of functions.
As a matter of fact I speak - Okej. You adjusted to operation with STDOUT the difficult theory only for this purpose
That all previous theories did not break. But I - as that king in  to a song
Asked "Only oils for a breakfast to me a tax".
Yes forgive me my impatience but what here not and why output did not work?

``````main = do
putStr "Enter you name:"
name &lt;- getLine
putStr ("Hello" ++ name)``````

mayton wrote:

And it is possible somehow  these  for the theory? I after all need to arrange
Some calls of functions.

Well so while you also should not know these theories.