ninetynine-1.3.0: Ninety-Nine Haskell Problems
CopyrightCopyright (C) 2021 Yoo Chung
LicenseGPL-3.0-or-later
Maintainerdev@chungyc.org
Safe HaskellSafe-Inferred
LanguageGHC2021

Solutions.P18

Description

Some solutions to Problems.P18 of Ninety-Nine Haskell Problems.

Synopsis

Documentation

slice :: [a] -> Int -> Int -> [a] Source #

Extract a slice from a list.

Given two indices, i and k, the slice is the list containing the elements between the i'th and k'th element of the original list, with both limits included. Start counting the elements with 1.

Go through individual elements in the list, dropping them and then keeping some of the rest.

slice' :: [a] -> Int -> Int -> [a] Source #

Extract a slice from a list.

Given two indices, i and k, the slice is the list containing the elements between the i'th and k'th element of the original list, with both limits included. Start counting the elements with 1.

drop and then take.