Does Haskell have similar syntactic sugar to Python List Slices?
For instance in Python:
x = [\'a\',\'b\',\'c\',\'d\']
x[1:3]
give
Why not use already existing Data.Vector.slice
together with Data.Vector.fromList
and Data.Vector.toList
(see https://stackoverflow.com/a/8530351/9443841)
import Data.Vector ( fromList, slice, toList )
import Data.Function ( (&) )
vSlice :: Int -> Int -> [a] -> [a]
vSlice start len xs =
xs
& fromList
& slice start len
& toList