| Author |
Message |
< Erlang ~ function clause error |
| billy-rat |
Posted: Wed Apr 09, 2008 12:06 pm |
|
|
|
Joined: 09 Apr 2008
Posts: 4
|
Hello Forum,
I try to write a program which calculates prime numbers from 2 to "bis". (sry german sourcecode )
Erl is printing many errors, but i don't know why. (This is my first erlang code with more then 3 lines )
Code:
-export([primzahlen/2]).
-export([modulo/2]).
primzahlen(bis) when bis > 1 ->
primzahlen(2, bis).
primzahlen(von, bis) when von < bis ->
is_prim = istPrim(von),
if
is_prim ->
io:fwrite("später die ausgabe von von")
end,
primzahlen(von+1,bis).
istPrim(z) when z < 2 -> false;
istPrim(z) -> istPrim(2,math:sqrt(z)).
istPrim(i, z) when i==z -> true;
istPrim(i, z) when i<z ->
is_rfd = modulo(z, i),
if
is_rfd == 0 ->
false;
true ->
istPrim(i+1,z)
end.
modulo(a,b) ->
z = trunc(a/b),
if z*b == a -> true;
true -> false
end.
erl:
Code: c(prim).
./prim.erl:9: Warning: no clause will ever match
./prim.erl:9: Warning: the guard for this clause evaluates to 'false'
./prim.erl:11: Warning: no clause will ever match
./prim.erl:12: Warning: the guard for this clause evaluates to 'false'
./prim.erl:15: Warning: this expression would cause a 'badarith' exception at run-time
./prim.erl:17: Warning: the guard for this clause evaluates to 'false'
./prim.erl:20: Warning: the guard for this clause evaluates to 'false'
./prim.erl:24: Warning: the guard for this clause evaluates to 'false'
./prim.erl:27: Warning: this expression would cause a 'badarith' exception at run-time
./prim.erl:31: Warning: this expression would cause a 'badarith' exception at run-time
./prim.erl:32: Warning: this expression would cause a 'badarith' exception at run-time
{ok,prim}
prim:primzahlen(10).
=ERROR REPORT==== 9-Apr-2008::14:01:12 ===
Error in process <0.196.0> with exit value: {function_clause,[{prim,primzahlen,"\n"},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
** exited: {function_clause,[{prim,primzahlen,"\n"},
{erl_eval,do_apply,5},
{shell,exprs,6},
{shell,eval_loop,3}]} **
Any ideas?
Thanks.. |
|
|
| Back to top |
|
| ppolv |
Posted: Wed Apr 09, 2008 7:44 pm |
|
|
|
Joined: 17 Jan 2008
Posts: 2
Location: Argentina
|
Hi,
variable names in erlang must start with an Uppercase letter. 'von','bis' are atoms, not variables. |
|
|
| Back to top |
|
| wuji |
Posted: Mon Aug 20, 2012 8:31 am |
|
|
|
User
Joined: 10 Aug 2012
Posts: 654
|
age the way of her mother, Judy Loe, 65."I much much replica designer *beep* much prefer how my mother looks to the people I
here [in Los Angeles] with wind-tunnel face," Beckinsale, who turns turns imitation designer *beep* turns 39 at the end of this month, tells the
edition of Glamour magazine."I feel like beauty is a gift gift jordan 6 olympic gift that you have for a while, and you enjoy
hell out of it while you have it," she tells tells cheap designer *beep* tells the August issue. "And if you're lucky enough to
a daughter and you give it to her, you enjoy enjoy cheap Ralph Lauren enjoy the fact she has it. My mother was always
very beautiful -- she still is, in her sixties."Beckinsale also also [h3]jordan 6[/h3] also lashed out against the pressure put on new celebrity
to bounce back after their pregnancies."There's an obsessional hatred of of cheap polo ralph lauren of normal human processes. Pregnancy changes a woman's body and
It isn't normal to not look like you've had a a cheap designer *beep* a baby immediately after you've had a baby."Fortunately for Beckinsale, |
|
|
| Back to top |
|
| dongdongwu |
Posted: Thu Sep 20, 2012 3:22 am |
|
|
|
User
Joined: 19 Sep 2012
Posts: 236
|
His good friend Diane said: "Christian Louboutin Men Shoes was a magician, he make shoes is immediately put his female people with legs and advantage. He understands women wanted to do and can make them into beautiful Cinderella." Madonna often in its concert wearing Christian louboutin high heels , and some famous superstar like Angelina jolie, mariah Carey, beyonce Knowles, the famous Japanese singer YaYouMei Hamasaki helps Christian Louboutin Men Shoes set up its powerful position. The youngest customers will count Tom cruise's daughter sully cruz. Louboutin made for only a pair of handmade Christian Louboutin high heel Shoes! Want to be more fashion? Put on Christian Louboutin Outlet !
Candy colors of the chalaza high-heeled shoes with lolita type allure, set full finely gem blue "neon shoes" is to need to use "sexy" to describe. Each pair are worth careful appreciation of lithe and graceful fairy ludaoli, what kind of most let you move?Christian Louboutin Men Shoes that one brush red is always cannot resist the temptation, Christian Louboutin men outlet continue to use the days of high 8cm above slender heel proclaim the sexy and luxuriant. The bowknot on black pointed high-heeled shoes with sharp rivet concomitant, wild python met enchanting color printing grain, It is that pairs of high-heeled shoes lets Carrie more feminine flavour. Like Christian Louboutin for men her word. |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|