-- 0.14 imports
--import List (..)
--import Basics (..)
import List exposing (..)
import Basics exposing (..)
fibonacci : Int -> List Int
fibonacci n =
let fibonacci' n acc =
if n <= 2
then acc
else fibonacci' (n-1) ((head acc + (tail >> head) acc) :: acc)
in
fibonacci' n [1,1] |> reverse
fibonacciWithIndexes : Int -> List (Int, Int)
fibonacciWithIndexes n = map2 (,) [0..n] (fibonacci n)
head : List a -> Maybe a
--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
barColor : Int -> Color
barColor n =
let colors = [ red, orange, yellow, green, blue, purple, brown ]
in
drop (n % (length colors)) colors |> head
Type mismatch between the following types between lines 13 and 15:
Color.Color
Maybe.Maybe Color.Color
It is related to the following expression:
let colors = [red,orange,yellow,green,blue,purple,brown]
in (drop (n % (length colors)) colors) |> head
So my question is this... if I am expecting a Color.Color to be returned, what do I need to add/change in this code to take the returned Maybe.Maybe into account? I assume that since the signature of head is..
<function> : List a -> Maybe.Maybe a
that this is something I am going to run into every time I use head, so I may as well try and get this straight in my head now (twisted head reference intended).
Thanks,
Bryan
Maybe an FAQ/Recipe/Cookbook area should be set up where we can collect these rookie mistakes and show simple solutions like the one you gave me.