{
else Fib
(n -
1) + Fib
(n -
2)
}
import scala.
annotation.
tailrec
def Fib
_tr
(n
: Int
): Int
=
{
@tailrec
def Fibb
(n
: Int, fib1
: Int, fib2
: Int
): Int
=
else Fibb
(n -
1, fib2, fib1 + fib2
)
Fibb(n,0, 1)
}
import scala.
annotation.
tailrec
def me
_Kill
_Myself
(a
: Double
): Double
= {
@tailrec
def root3
_tl
(x
: Double
): Double
= {
if (math.
abs(math.
pow(x,
3) - a
) <= 1.0E-15
* Math.
abs(a
)) x
else root3
_tl
(x +
(a / math.
pow(x,
2) - x
) /
3)
}
root3
_tl
(if (a
> 1) a/
3 else a
)
}
me_Kill_Myself (27)
val x1
= (-
2, -
1,
0,
1,
2)
val x2
= ((1,
2),
(0,
1))
val ((_,
_),
(x,
_)) = x2
def initSegment
[A
] (xs1
: List
[A
], xs2
: List
[A
]): Boolean
= {
// val h1::t1 = xs1
// val h2::t2 = xs2
else if (xs1.
head == xs2.
head) initSegment
(xs1.
tail, xs2.
tail)
}
initSegment(l2, l1)
def replaceNth
[A
] (xs
:List
[A
], n
: Int, el
: A
): List
[A
] =
{
if (n
< 0 || xs
== Nil
) throw new Exception
("Dupa")
else if (n
== 0) el
:: xs.
tail
else xs.
head :: replaceNth
(xs.
tail,n-
1,el
)
}
replaceNth('a' :: 'b' :: 'c' ::Nil, 0, 'd')
Replies to Untitled
Title |
Name |
Language |
UNIX |
When |
Re: Untitled |
Queen Camel |
scala |
1508185326 |
6 Years ago. |
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}