Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Fibonnaci error
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
xancorreu  
View profile  
 More options Apr 11 2012, 8:08 am
From: xancorreu <xancor...@gmail.com>
Date: Wed, 11 Apr 2012 14:08:08 +0200
Local: Wed, Apr 11 2012 8:08 am
Subject: Fibonnaci error
I don't know why this code:

FUNC fibo(int a) int
     IF a <= 2
         RETURN 1
     ELSE
         RETURN fibo(a - 1) + fibo(a - 2)
     }
     RETURN 0

}

FUNC MAIN() int
      IF ARG.size() != 0
          IO.write(fibo(ARG.get(0)))
      ELSE
          IO.write("Falten arguments\n")
      }
   RETURN 0

}

produces me an error:

$ ../zimbu fibonnaci.zu
fibonnaci.zu line 13 col 13: ERROR: More than one method with matching
arguments for write(unknown)
fibonnaci.zu line 721 col 3: ERROR: here
fibonnaci.zu line 715 col 3: ERROR: and here
fibonnaci.zu line 13 col 13: ERROR: builtinModule member not found: write

Anyone could help me?
Thanks in advance,
Xan.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bram Moolenaar  
View profile  
 More options Apr 11 2012, 2:24 pm
From: Bram Moolenaar <B...@Moolenaar.net>
Date: Wed, 11 Apr 2012 20:24:09 +0200
Local: Wed, Apr 11 2012 2:24 pm
Subject: Re: Fibonnaci error

Note that the file names are wrong in the last three errors.  That's a
known bug.

The actual error is somehow not printed.  I'll see if I can fix that.

The problem in your code is that ARG.get(0) returns a string, but the
fibo() function requires an int.  This will work:

FUNC MAIN() int
      IF ARG.size() != 0
          IO.write(fibo(ARG.get(0).toInt()))
      ELSE
          IO.write("Falten arguments\n")
      }
   RETURN 0

}

--
MORTICIAN:    What?
CUSTOMER:     Nothing -- here's your nine pence.
DEAD PERSON:  I'm not dead!
MORTICIAN:    Here -- he says he's not dead!
CUSTOMER:     Yes, he is.
DEAD PERSON:  I'm not!
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- B...@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Xan  
View profile  
 More options Apr 11 2012, 3:52 pm
From: Xan <xancor...@gmail.com>
Date: Wed, 11 Apr 2012 12:52:22 -0700 (PDT)
Local: Wed, Apr 11 2012 3:52 pm
Subject: Re: Fibonnaci error

On Apr 11, 8:24 pm, Bram Moolenaar <B...@Moolenaar.net> wrote:

Please, fix it.

> The problem in your code is that ARG.get(0) returns a string, but the
> fibo() function requires an int.  This will work:

> FUNC MAIN() int
>       IF ARG.size() != 0
>           IO.write(fibo(ARG.get(0).toInt()))
>       ELSE
>           IO.write("Falten arguments\n")
>       }
>    RETURN 0

> }

Thanks.
Just a suggestion: invoke IO.write with multiple arguments:
IO.write("Integer", 3, "is odd")
now produces an error

Thanks,
Xan.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bram Moolenaar  
View profile  
 More options Apr 11 2012, 5:02 pm
From: Bram Moolenaar <B...@Moolenaar.net>
Date: Wed, 11 Apr 2012 23:02:05 +0200
Local: Wed, Apr 11 2012 5:02 pm
Subject: Re: Fibonnaci error

I just pushed the fix.

Use: IO.write("Integer " .. 3 .. " is odd")

--
We do not stumble over mountains, but over molehills.
                                Confucius

 /// Bram Moolenaar -- B...@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »