Earlier quoted context omitted.
What is it?
Similar to 'let' (or 'letrec' in lisps), but written after the block it applies to. For example: average xs = total / count where total = sum xs count = length xs
PyFL – new functional programming language from Bill Wadge
31–40 of 51 posts
Re: PyFL – new functional programming language from Bill Wadge
#32Earlier quoted context omitted.
Haskell is more versatile: f(a, b) is a function applied to a single tuple, f a b is a function applied to two arguments. I do not understand the "instead of" in the cited part and it makes me somewhat skeptical (so does the "Py" in the name).
In python, f(a, b) is a function applied to two arguments and f((a, b)) is a function applied to a single tuple.
https://en.wikipedia.org/wiki/Argument_of_a_function
"For example, the binary function f(x, y) = x + y has two arguments, x and y, in an ordered pair (x, y)."
So, function application to an ordered pair, i.e., a tuple, does not use double parentheses. Also, of course, currying in Python is atrocious.
Re: PyFL – new functional programming language from Bill Wadge
#33Earlier quoted context omitted.
Here's a historical one. 1976. https://en.wikipedia.org/wiki/SASL_(programming_language)
Indeed, these languages are descendants of ISWIM by Peter Landin. ISWIM also inspired Lucid, so I guess PyFL would be a nephew of SASL in that case.
Re: PyFL – new functional programming language from Bill Wadge
#34That said, i do prefer PyFl's lambda syntax.
This is definitely a cool project, i could see myself using this.
Re: PyFL – new functional programming language from Bill Wadge
#35Earlier quoted context omitted.
Indeed, these languages are descendants of ISWIM by Peter Landin. ISWIM also inspired Lucid, so I guess PyFL would be a nephew of SASL in that case.
ISWIM isn't lazy, I think, nor fully functional.
Re: PyFL – new functional programming language from Bill Wadge
#36> … valof clauses (basically where clauses) I so wish Python had valof/where already. And it’s the one feature I was surprised not to find in OCaml after seeing it in Haskell – why isn’t it more common?
Re: PyFL – new functional programming language from Bill Wadge
#37I wonder if the niche of functional language with a lightweight syntax is already being served by F#?
Re: PyFL – new functional programming language from Bill Wadge
#38Earlier quoted context omitted.
Similar to 'let' (or 'letrec' in lisps), but written after the block it applies to. For example: average xs = total / count where total = sum xs count = length xs
best define `average []` first
average (x, xs) = total / count
where (total, count) = Data.List.foldl' go (x, 1) xs
go (total, count) x = (total + x, count + 1)
In a naive interpreter, this will do one pass rather than two. A smart compiler like GHC can probably optimise away the entire list, getting a tight numeric loop (e.g. https://dl.acm.org/doi/10.1145/1291220.1291199 )Re: PyFL – new functional programming language from Bill Wadge
#39I wonder if the niche of functional language with a lightweight syntax is already being served by F#?