val xs
= 1 :: 2 :: 3 :: 4 :: 5 :: 6 :: 7 :: 8 :: Nil
def nTy
[A
](xs
: List
[A
], n
: Int
):A
= {
case(_,
_) => nTy
(t, n -
1)
}
}
nTy(xs, 3)
def podzielPoN
[A
](a
: List
[A
], n
: Int
): List
[List
[A
]] = {
def podzielPoN
_tr
[A
](a
: List
[A
], n
: Int, b
: List
[A
]): List
[List
[A
]] = {
else podzielPoN
_tr
(a.
tail, n -
1, b ++ List
(a.
head))
}
podzielPoN_tr(a,n, List[A]())
}
podzielPoN(xs, 2)
def podzielWgMod
[A
](list
: List
[Int
], n
: Int
): List
[List
[Int
]] = {
def podzielWgMod
_tr
(xs
: List
[Int
], a
: List
[Int
], b
: List
[Int
]): List
[List
[Int
]] = {
if (xs
== Nil
) List
(a, b
)
else if (xs.
head % n
== 0) podzielWgMod
_tr
(xs.
tail, a ++ List
(xs.
head), b
)
else podzielWgMod
_tr
(xs.
tail, a, b ++ List
(xs.
head))
}
podzielWgMod_tr(list, List(), List())
}
podzielWgMod(xs, 2)
def coNTy
[A
](xs
: List
[A
], n
: Int
): List
[A
] = {
def coNTy
_it
[A
](x
: List
[A
], i
: Int
): List
[A
] = {
else if (i
== 1) x.
head :: coNTy
_it
(x.
tail, n
)
else coNTy
_it
(x.
tail, i -
1)
}
coNTy_it(xs, n)
}
coNTy(xs, 3)
}
Replies to Untitled
Title |
Name |
Language |
UNIX |
When |
Re: Untitled |
Wet Butterfly |
scala |
1508279521 |
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"}