Does Haskell have a splat operator like Python and Ruby?

前端 未结 3 1549
忘了有多久
忘了有多久 2021-01-01 19:23

In Python and Ruby (and others as well, I\'m sure). you can prefix an enumerable with * (\"splat\") to use it as an argument list. For instance, in Python:

3条回答
  •  灰色年华
    2021-01-01 20:27

    No, Haskell's type system doesn't like that. Check this similar question for more details:

    How do I define Lisp’s apply in Haskell?

    BTW, the splat operator you talk about is also known as the apply function, commonly found on dynamical functional languages (like LISP and Javascript).

提交回复
热议问题