Hi guys,
I'm new to programming and just starting out in Haskell, and I came across \\ in some code. I've been unable to search for what it does because search engines do not recognise it as a word. Can someone help me out?
Thanks! :)
4 replies to this topic
#1
Posted 17 May 2011 - 06:08 AM
|
|
|
#2
Posted 17 May 2011 - 08:38 AM
In Haskell, the backslash ('\') character is used to represent lambda functions. A double backslash is an escaped backslash, i.e., a way of representing a literal backslash character.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
#3
Posted 28 January 2012 - 07:55 PM
Well I guess gregwarner's answer was not helpful. It was not for me anyway.
(\\) (double backslash) function in Haskell is a list difference function as found in Data.List module (Data/List.hs)
Implementation:
(\\) :: (Eq a) => [a] -> [a] -> [a]
(\\) = foldl (flip delete)
It accepts 2 lists and deletes the first occurrence of each element of the second list from the first list.
Examples:
(\\) [1,2,3] [2,3,4]
> [1]
(\\) [1,2,3,4,5] [2,3,4]
> [1,5]
(\\) [1,2,2] [2]
> [1,2] -- See how only one "2" is deleted from the original list.
(\\) (double backslash) function in Haskell is a list difference function as found in Data.List module (Data/List.hs)
Implementation:
(\\) :: (Eq a) => [a] -> [a] -> [a]
(\\) = foldl (flip delete)
It accepts 2 lists and deletes the first occurrence of each element of the second list from the first list.
Examples:
(\\) [1,2,3] [2,3,4]
> [1]
(\\) [1,2,3,4,5] [2,3,4]
> [1,5]
(\\) [1,2,2] [2]
> [1,2] -- See how only one "2" is deleted from the original list.
#4
Posted 28 January 2012 - 09:56 PM
"The best optimizer is between your ears" - Michael Abrash
Saying you can optimize a program is like saying you understand how a program works on every level of every facet on a specific machines configuration.
Saying you can optimize a program is like saying you understand how a program works on every level of every facet on a specific machines configuration.
#5
Posted 30 January 2012 - 06:28 AM
Thanks for the correction. Got mixed up there.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top










