How can I get nth element from a list?

前端 未结 7 673
长发绾君心
长发绾君心 2020-12-12 18:51

How can I access a list by index in Haskell, analog to this C code?

int a[] = { 34, 45, 56 };
return a[1];
7条回答
  •  再見小時候
    2020-12-12 19:24

    Look here, the operator used is !!.

    I.e. [1,2,3]!!1 gives you 2, since lists are 0-indexed.

提交回复
热议问题