1. Eu Doc's

Hi Robert Hi All,
  I am not new to Euphoria but I have not used Euphoria in a very long 
time.  Anyway I am back with Euphoria again and I can't remember some 
things about it.  I clipped this from the documentation but I am not 
understanding something here and I know this may seem simple but here it 
goes anyway.  In Example 2 below what variable type is "i" in the line 
"for i = 1 to length(x) do".  I tried this same simple for loop and 
declared i as an integer but when I run the program it says that I am 
trying to redefine that variable.  If anyone could give me a kick start 
back into Eu I would greatly appreciate it.

sequence
Syntax: i = sequence(x)  
Description: Return 1 if x is a sequence else return 0.  
Comments: This serves to define the sequence type. You can also call it 
like an ordinary function to determine if an object is a sequence.  
Example 1:  
 sequence s
s = {1,2,3}


 
Example 2:  
 if sequence(x) then
    sum = 0
    for i = 1 to length(x) do
        sum = sum + x[i]
    end for
else
    -- x must be an atom
    sum = x
end if


 


See ya on the Netsmile
MindPower

new topic     » topic index » view message » categorize

2. Re: Eu Doc's

> Hi Robert Hi All,
>   I am not new to Euphoria but I have not used Euphoria in a very long 
> time.  Anyway I am back with Euphoria again and I can't remember some 
> things about it.  I clipped this from the documentation but I am not 
> understanding something here and I know this may seem simple but here it 
> goes anyway.  In Example 2 below what variable type is "i" in the line 
> "for i = 1 to length(x) do".  I tried this same simple for loop and 
> declared i as an integer but when I run the program it says that I am 
> trying to redefine that variable.  If anyone could give me a kick start 
> back into Eu I would greatly appreciate it.

the for..do..end for statement automatically declares the counter
variable. That means that you do not need to (and indeed cannot)
declare it yourself. You can use the counter (i) within the for loop
but not outside it.

Thomas Parslow (PatRat) ICQ #:26359483
Rat Software
http://www.rat-software.com/
Please leave quoted text in place when replying

new topic     » goto parent     » topic index » view message » categorize

3. Re: Eu Doc's

> Hi Thomas,
> Thank you for the information but that still does not tell me what type 
> of variable "i" is????  I guess my point is what type of variable does 
> the length() routine return?  I thought it was an integer but I guess it 
> is some other type???? 
>
>
> See ya on the Netsmile
> MindPower

sorry, missed the question :)
Euphoria doesn't really have data types like most other languages,
in the example you gave i is an atom (it's also an Integer
because it never takes on a fractional value).

Thomas Parslow (PatRat) ICQ #:26359483
Rat Software
http://www.rat-software.com/
Please leave quoted text in place when replying

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu