Name: Anonymous 2008-12-16 19:36
Hey /prog/,
I know you normally don't give do other peoples homework, but I just can't get this to compile and its due tomorrow. Can anyone help me figure out what the problem is?
I know you normally don't give do other peoples homework, but I just can't get this to compile and its due tomorrow. Can anyone help me figure out what the problem is?
brotataylor =
(
taylor
*
{
fj”ltilstuŒull ->
stef(;x)
stofn
x \brot 1
stofnlok
skrifastuŒul -> skrifabrot
}
:
{
brot -> brot
**** -> *
skrifabrot ->
stef(;x)
stofn
skrifastaf(;'('),
skrifaheil(;\teljari x),
skrifastaf(;'/'),
skrifaheil(;\nefnari x),
skrifastaf(;')'),
stofnlok
}
)
*
"brot"
*
{
+ -> ++
- -> --
* -> **
/ -> //
< -> <<
-> >>
= -> ==
<= -> <=<=
>=>= -> >=>=
<> -> <><>
gcd -> hgcd
n£ll -> stef(;) stofn 0 stofnlok
}
:
( "storheil" * "storfjol" )
;
;; Lesum grunninn inn og leggjum hann minniŒ •v¡ viŒ notum hann tvisvar:
grunnur = "grunnur4" ;
"bern" < aŒal
{
aŒal ->
stef(;)
staŒv‘r n,m,s,c,t
stofn
skrifastreng(;"Forrit •etta reiknar Bernoulli-t”lurnar B(2),...,B(2n)"),
n˜l¡na(;),
skrifastreng(;"HvaŒa 2n viltu? "),
m:=lesa(;),
s:=\sin m,
c:=\cos m,
fyrir(n:=1, t:=\leif (s/c) ; t ; t:=\leif \leif t, n:=\st‘kka n) lykkja
skrifastreng(;"B("), skrifaheil(;2**n), skrifastreng(;")="),
skrifabrot(;
(\fyrsti t) ****
(
(\hr¢p (2**n))
\brot
(((-1)^^(n--1)) ** (s:=2^^(2**n)) ** (s--1))
)
),
n˜l¡na(;),
lykkjulok,
stofnlok
}
*
!
{
hr¢p ->
stef(;n)
stofn
ef n==0 • 1 annars n**\hr¢p(n--1) eflok,
stofnlok
^^ ->
stef(;x,n)
stofn
ef n=0 • 1
annarsef n%%2=1 •
x**((x**x)^^(n//2)),
annars
(x**x)^^(n//2),
eflok,
stofnlok
}
*
brotataylor
*
grunnur
;
;; ViŒ •urfum ekki meira brotataylor aŒ halda:
brotataylor = {} ;
fleytitaylor =
taylor
*
{
+ -> +++
- -> ---
* -> ***
/ -> ///
= -> ===
fj”ltilstuŒull -> fj”ltilfleyt
skrifastuŒul -> skrifa
}
;
;; ViŒ •urfum ekki lengur taylor aŒ halda:
taylor = {} ;
;; ¥ eftirfarandi forriti eru Bernoulli-t”lurnar reiknaŒar meŒ
;; fleytit”lureikningum. etta forrit er miklu hraŒvirkara en
;; forritiŒ aŒ ofan, en aŒ sama skapi ¢n kv‘mara.
"bernf" < aŒal
{
aŒal ->
stef(;)
staŒv‘r n,m,s,c,t
stofn
skrifastreng(;"Forrit •etta reiknar Bernoulli-t”lurnar B(2),...,B(2n)"),
n˜l¡na(;),
skrifastreng(;"HvaŒa 2n viltu? "),
m:=lesa(;),
s:=\sin m,
c:=\cos m,
fyrir(n:=1, t:=\leif (s/c) ; t ; t:=\leif \leif t, n:=\st‘kka n) lykkja
skrifastreng(;"B("), skrifaheil(;2**n), skrifastreng(;")="),
skrifa(;
\fyrsti t ***
(\hr¢p (2**n)) /// (-1.0^^^(n--1)) /// (s:=2.0^^^(2**n)) /// (s---1.0)
),
n˜l¡na(;),
lykkjulok,
stofnlok
}
*
!
{
hr¢p ->
stef(;n)
stofn
ef n==0 • 1.0 annars \fj”ltilfleyt n *** \hr¢p(n--1) eflok,
stofnlok
^^^ ->
stef(;x,n)
stofn
ef n=0 •
1.0
annarsef n%%2=1 •
x***((x***x)^^^(n//2)),
annars
(x***x)^^^(n//2),
eflok,
stofnlok
}
*
fleytitaylor
*
"GRUNNUR"
;