Re: string to Integer

2000-04-07 Thread Jon Fairbairn
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

Re: string to Integer

2000-04-07 Thread George Russell
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

Re: string to Integer

2000-04-07 Thread Frank Atanassow
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

Re: string to Integer

2000-04-07 Thread Frank Atanassow
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

Re: string to Integer

2000-04-07 Thread Marcin 'Qrczak' Kowalczyk
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]

Re: string to Integer

2000-04-06 Thread George Russell
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

Re: string to Integer

2000-04-06 Thread Ralf Muschall
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

Re: string to Integer

2000-04-06 Thread Ronny Wichers Schreur
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:

Re: string to Integer

2000-04-06 Thread Ronny Wichers Schreur
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

Re: string to Integer

2000-04-06 Thread Yuichi Tsuchimoto
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

string to Integer

2000-04-05 Thread Friedrich Dominicus
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

Re: string to Integer

2000-04-05 Thread Arjan van IJzendoorn
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

Re: string to Integer

2000-04-05 Thread Friedrich Dominicus
"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

Re: string to Integer

2000-04-05 Thread Marcin 'Qrczak' Kowalczyk
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

backwards stuff (was re: string to integer)

2000-04-05 Thread Peter Hancock
"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

Re: string to Integer

2000-04-05 Thread Hamilton Richards
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"

Re: string to Integer

2000-04-05 Thread Peter Hancock
"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

Re: string to Integer

2000-04-05 Thread Ronny Wichers Schreur
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