I wasn't very far ^^ here is the function: location : Int -> Int -> ( Int, Int ) -> ( Int, Int ) -> Maybe ( Int, Int ) location bufferIndex offset ( str1, str2 ) ( height, width ) = let unOffset = bufferIndex - offset
( line, lineRest ) = ( unOffset // str1 , unOffset % str1 ) ( column, columnRest ) = ( lineRest // str2 , lineRest % str2 ) locationOk = line < height && column < width && columnRest == 0 in if locationOk then Just ( line, column ) else Nothing You can easily verify your example by putting it in a file, and in elm-repl: import TheFile import List List.range 0 8 |> List.map (\id -> TheFile.location id 0 (6,2) (2,2)) -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.