Does Haskell have List Slices (i.e. Python)?

后端 未结 12 1044
南方客
南方客 2020-12-05 02:15

Does Haskell have similar syntactic sugar to Python List Slices?

For instance in Python:

x = [\'a\',\'b\',\'c\',\'d\']
x[1:3] 

give

12条回答
  •  孤城傲影
    2020-12-05 02:42

    No syntactic sugar. In cases where it's needed, you can just take and drop.

    take 2 $ drop 1 $ "abcd" -- gives "bc"
    

提交回复
热议问题