Re: [elm-discuss] Arbitrary length currying

2017-11-17 Thread Adrian Roe
I’m pretty certain you can’t do this in elm. The ellie is for f [] and f [3,9,2] whereas the question is for f [] and f [3] [9] [2] [] In the latter example, you need f [] to return an integer and f [3] to return a function that takes two lists of integers and a list of any type and returns an

Re: [elm-discuss] Arbitrary length currying

2017-11-07 Thread Matthew Bray
It's not quite what you asked for, but Kris Jenkins' Formatting[0] library does some interesting stuff with variadic functions. In that library, the `print` function's arity depends on the value of its first argument. Here's the idea applied to this problem (code lifted straight from the Formattin

Re: [elm-discuss] Arbitrary length currying

2017-11-06 Thread Ray Toal
I like the calls and resolves! Nice. On Monday, November 6, 2017 at 8:45:48 PM UTC-8, David Andrews wrote: > > Sorry I misread your example as a single list argument. > > Strictly speaking, you can not call a function with no arguments in Elm, > but some functions take Unit as an argument. > > Th

Re: [elm-discuss] Arbitrary length currying

2017-11-06 Thread David Andrews
Sorry I misread your example as a single list argument. Strictly speaking, you can not call a function with no arguments in Elm, but some functions take Unit as an argument. There are a couple of roadblocks preventing this exact functionality in Elm. Firstly, Elm does not allow recursive types <

Re: [elm-discuss] Arbitrary length currying

2017-11-06 Thread Ray Toal
Thanks but I was looking not for the obvious, practical approach for summing integers but was interested in the puzzle of arbitrary-length currying. When called with no arguments, the function should yield its sum so far. When called with a single argument, the function should return a function

Re: [elm-discuss] Arbitrary length currying

2017-11-06 Thread David Andrews
The solution for the list version is very straightforward in elm: https://ellie-app.com/g4DpfMDxPa1/0 On Sun, Nov 5, 2017 at 10:39 PM, Ray Toal wrote: > There's an interesting problem on the Programming Puzzles and Stack > Exchange on arbitrary length currying here: https://codegolf. > stackexch

[elm-discuss] Arbitrary length currying

2017-11-05 Thread Ray Toal
There's an interesting problem on the Programming Puzzles and Stack Exchange on arbitrary length currying here: https://codegolf.stackexchange.com/questions/117017/arbitrary-length-currying. It asks for a function f behaving as follows: f () = 0 f (3)(9)(2)() = 14 This is trivial in d