
2009/1/3 Xie Hanjian
* Luke Palmer
[2009-01-03 18:46:50 -0700]: 2009/1/3 Xie Hanjian
Hi,
I tried this in ghci:
Prelude> 1:2:[] == 1:2:[] True
Does this mean (:) return the same object on same input,
Also, in functional programming, *every* function returns the same output for the same input. That's part of the definition of function. :-)
This is true in Haskell, but may not true in Scheme (I guess also false in Lisp).
I, like many arrogant Haskellers, reject Scheme and other such impure languages as "functional". At least until I turn on my brain. So, revise the beginning of my statement to "Also, in *pure* functional programming, ..." Luke
In DrScheme:
(eq? (cons 1 2) (cons 1 2)) #f (equal? (cons 1 2) (cons 1 2)) #t
Although equal? treats the two as the *same*, they're different lists because if we modify one (e.g by set-car!) the other won't be affected.
So here comes another question: when we say a function always give the same output for the same input, what the *same* means here? ídentity or equality?
Thanks Jan
Luke
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- jan=callcc{|jan|jan};jan.call(jan)
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe