99 Elm Problems/Problem 18

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Extract a sublist from a list, starting and ending at specified indices (inclusive). Start counting the elements with 1.

import Html exposing (text)
import List

sublist : Int -> Int -> List a -> List a
-- your implementation goes here

main = 
  text <| toString <|
    sublist 3 7 [1..10]

Result:

[3, 4, 5, 6, 7]

Solutions