Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using symbol before it is definied

Tags:

haskell

How is it that in line below on the right side of equation one could use symbol 'fibs' although it is not yet definied:

let fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
like image 495
Trismegistos Avatar asked Mar 25 '12 21:03

Trismegistos


People also ask

What is the symbol of not defined?

Is there any symbol for representing it? It is common to write "DNE" for "does not exist". My preferred symbol is not to write undefined things, the empty symbol.

Why do we use symbol?

Symbols facilitate understanding of the world in which we live, thus serving as the grounds upon which we make judgments. In this way, people use symbols not only to make sense of the world around them, but also to identify and cooperate in society through constitutive rhetoric.

What is the system of symbols?

System symbols are elements that allow systems to share parmlib definitions while retaining unique values in those definitions. System symbols act like variables in a program; they can take on different values, based on the input to the program.


1 Answers

The point is that the definition of fibs

fibs = 0 : 1 : zipWith (+) fibs (tail fibs)

is not evaluated until it is used somewhere else. Then the definition unfolds using the already known part. We begin with fibs = 0 : 1 : ???. Then if the third element is ever needed, the definition is evaluated one step further,

fibs = 0 : 1 : zipWith (+) (0 : 1 : ???) (tail (0 : 1 : ???))
     = 0 : 1 : zipWith (+) (0 : 1 : ???) (1 : ???)
     = 0 : 1 : (0 + 1) : zipWith (+) (1 : ???) (???)

but then the unknown part ??? has become partly known, it has been determined to be ??? = 1 : ????, so the unfolding can go on,

     = 0 : 1 : 1 : zipWith (+) (1 : 1 : ????) (1 : ????)
     = 0 : 1 : 1 : 2 : zipWith (+) (1 : ????) (????)
     -- now ???? is known to be 2:?????
     = 0 : 1 : 1 : 2 : zipWith (+) (1 : 2 : ?????) (2 : ?????)

etc.

like image 133
Daniel Fischer Avatar answered Sep 30 '22 09:09

Daniel Fischer