IK
Size: a a a
IK
MK
ЖК
go acc | acc /= stop = f acc <|> go (next acc)
.......| otherwise = Nothing
go acc
.....| acc /= stop =
.........case f acc of
..........Nothing -> go (next acc)
..........result -> result
.....| otherwise = Nothing
MK
MK
A
go acc | acc /= stop = f acc <|> go (next acc)
.......| otherwise = Nothing
go acc
.....| acc /= stop =
.........case f acc of
..........Nothing -> go (next acc)
..........result -> result
.....| otherwise = Nothing
MK
MK
MK
MK
ЖК
MK
MK
A
MK
ЖК
MK
FL
fibs :: [Integer]
fibs = 0:1:zipWith (+) fibs (tail fibs)
fib n = fibs !! n
perimeter :: Integer -> Integer
perimeter 0 = 4
perimeter n = (*) 4 $ sum f
where
f = foldl (\acc x -> fib x : acc) [] [1..n + 1]
• Couldn't match expected type ‘Int’ with actual type ‘Integer’
• In the expression: n + 1
In the third argument of ‘foldl’, namely ‘[1 .. n + 1]’
In the expression: foldl (\ acc x -> fib x : acc) [] [1 .. n + 1]
|
11 | f = foldl (\acc x -> fib x : acc) [] [1..n + 1]
ВЩ
fibs :: [Integer]
fibs = 0:1:zipWith (+) fibs (tail fibs)
fib n = fibs !! n
perimeter :: Integer -> Integer
perimeter 0 = 4
perimeter n = (*) 4 $ sum f
where
f = foldl (\acc x -> fib x : acc) [] [1..n + 1]
• Couldn't match expected type ‘Int’ with actual type ‘Integer’
• In the expression: n + 1
In the third argument of ‘foldl’, namely ‘[1 .. n + 1]’
In the expression: foldl (\ acc x -> fib x : acc) [] [1 .. n + 1]
|
11 | f = foldl (\acc x -> fib x : acc) [] [1..n + 1]
ВЩ
!!
принимает интовый индекс, вот