Then, the question is why we write
result = function operand1 operand2
instead of
operand1 operand2 function = result
I actually think the latter is cooler. :)
I think there may be cultural influences about word order and/
or writing direction creeping in here :-)
--
Jón Fairbairn
Jon Fairbairn wrote:
Then, the question is why we write
result = function operand1 operand2
instead of
operand1 operand2 function = result
I actually think the latter is cooler. :)
I think there may be cultural influences about word order and/
or writing direction creeping
Yuichi Tsuchimoto writes:
Or look at o's and flippo's types:
(.) :: ((a - b) - (c - a)) - (c - b)
flip (.) :: ((a - b) - (b - c)) - (a - c)
Surely the second one is much cooler!
Yes, indeed!
Then, the question is why we write
result = function
Frank Atanassow writes:
Using - in type signatures has the advantage that the first thing you see in
a signature is what is produced, rather than what is necessary to produce,
which is sometimes what you want when you have a set of algebraic functions
like John Hughes' pretty-printing
Thu, 06 Apr 2000 22:23:10 +0200, Ralf Muschall [EMAIL PROTECTED] pisze:
And if I call the label on the stones "integer_from_string"
and "integer_from_intlist", unflipped (.) does as well.
In OCaml such functions are called int_of_string etc.
--
__("Marcin Kowalczyk * [EMAIL PROTECTED]
Ralf Muschall wrote:
Where does the habit to use "flip (.)" in many FP people come
from?
I think it may come partly from category
theorists
Ronny Wichers Schreur schrieb:
If you think of the (types of) functions as domino stones,
|. makes them fit.
And if I call the label on the stones "integer_from_string"
and "integer_from_intlist", unflipped (.) does as well.
The same applies to the other answers: On could write
f . g (which
Ralf Muschall wrote:
And if I call the label on the stones "integer_from_string"
and "integer_from_intlist", unflipped (.) does as well.
But then the question is which function name is more natural.
Arjen's choice of names reflects Haskell's syntax for function
types:
I wrote:
(.) :: ((a - b) - (c - a)) - (c - b)
flip (.) :: ((a - b) - (b - c)) - (a - c)
Hm, let me try that again:
(.) :: (a - b) - (c - a) - (c - b)
flip (.) :: (a - b) - (b - c) - (a - c)
Cheers,
Ronny Wichers Schreur
And if I call the label on the stones "integer_from_string"
and "integer_from_intlist", unflipped (.) does as well.
But then the question is which function name is more natural.
Arjen's choice of names reflects Haskell's syntax for function
types:
intlist_to_integer
I was again playing around with Haskell to learn it a bit better. I do not
found a function to turn a String into an Integer
This is what I come up with:
string_to_int_list :: String - [Int]
-- filter out all Digits first and then turn it into a list
-- of integers
string_to_int_list = filter
Hello Friedrich,
Turning a string into an integer is easy with the Prelude function 'read':
n :: Integer
n = read "-34232"
Your own function can be made to work for negative numbers by a simple
wrapper:
stringToInteger :: String - Integer
stringToInteger ('-':rest) = -string_to_in
"AvI" == Arjan van IJzendoorn [EMAIL PROTECTED] writes:
AvI Hello Friedrich,
AvI Turning a string into an integer is easy with the Prelude function 'read':
AvI n :: Integer
AvI n = read "-34232"
Yes, other have told me. As I mailed back I was just too bli
Wed, 05 Apr 2000 19:37:06 +0200, Ralf Muschall [EMAIL PROTECTED] pisze:
and the type declaration you gave seems to be the most general
possible anyway, i.e. it does not carry any information.
It does: documentation.
It happens that in this case "flip (.)" is more clear documentation
for me
"Marcin" == Marcin 'Qrczak' Kowalczyk [EMAIL PROTECTED] writes:
I don't know, I use non-flipped (.). But if we wrote function
application in the "argument + function" order, composition would
certainly be written backwards as well.
Actually, it makes good sense to think of
At 7:37 PM +0200 4/5/00, Ralf Muschall wrote:
Where does the habit to use "flip (.)" in many FP people come
from?
It's useful for composing several functions in pipeline fashion.
Simon Thompson (in his book _Haskell: the Craft of Functional Programming_)
defines a "forward composition"
"Hamilton" == Hamilton Richards [EMAIL PROTECTED] writes,
about forwards (is it backwards?) composition:
A composition using this operator, e.g.,
f . g . h
is easily understood as a pipeline in which data flows from left to right.
Using ordinary composition (.), the same
Arjan van IJzendoorn wrote the function:
string_to_integer :: String - Integer
string_to_integer = string_to_int_list .| int_list_to_integer
Ralf Muschall answered:
(|.) = flip (.)
[..]
Where does the habit to use "flip (.)" in many FP people
come from?
If you think of
18 matches
Mail list logo