haskell101.wordpress.com
Matching items | Haskell 101
https://haskell101.wordpress.com/2008/02/04/matching-items
February 4, 2008. Filed under: Functional programming. 8212; Haskell 101 blogger @ 8:02 pm. 1) matches: Int- [Int]- [Int]. As we did with our instances function, we start with the case that ends a recursion. 2) matches x [] = []. For the other cases, we’ll mimic the structure from our instances function. This time, though, instead of adding one to the total, we’ll simply add the matching item to the list we’re collecting. 3) matches x (y:ys). X= y = x:(matches x ys). Otherwise = matches x ys.
haskell101.wordpress.com
February | 2008 | Haskell 101
https://haskell101.wordpress.com/2008/02
February 4, 2008. Filed under: Functional programming. 8212; Haskell 101 blogger @ 8:02 pm. 1) matches: Int- [Int]- [Int]. As we did with our instances function, we start with the case that ends a recursion. 2) matches x [] = []. For the other cases, we’ll mimic the structure from our instances function. This time, though, instead of adding one to the total, we’ll simply add the matching item to the list we’re collecting. 3) matches x (y:ys). X= y = x:(matches x ys). Otherwise = matches x ys. All those e...
haskell101.wordpress.com
Checking for a value in a list | Haskell 101
https://haskell101.wordpress.com/2008/01/27/checking-for-a-value-in-a-list
January 27, 2008. Checking for a value in a list. Filed under: Functional programming. 8212; Haskell 101 blogger @ 9:24 pm. Once we have a list, how do we check whether that list contains a certain value? This is sort of like the Ruby method “include? We want to provide the value we are looking for, and the list in which we would like to look for it. 1) includes: Int- [Int]- Bool. Let’s first try using pattern matching and recursion. 2) includes x (y:ys). X= y = True. Otherwise = includes x ys. Notify me...
haskell101.wordpress.com
January | 2008 | Haskell 101
https://haskell101.wordpress.com/2008/01
January 27, 2008. Checking for a value in a list. Filed under: Functional programming. 8212; Haskell 101 blogger @ 9:24 pm. Once we have a list, how do we check whether that list contains a certain value? This is sort of like the Ruby method “include? We want to provide the value we are looking for, and the list in which we would like to look for it. 1) includes: Int- [Int]- Bool. Let’s first try using pattern matching and recursion. 2) includes x (y:ys). X= y = True. Otherwise = includes x ys. Let’...
haskell101.wordpress.com
About | Haskell 101
https://haskell101.wordpress.com/about
I enjoy programming as a hobby and wanted to share my exploration in learning more about Haskell. Leave a Comment ». Feed for comments on this post. Leave a Reply Cancel reply. Enter your comment here. Fill in your details below or click an icon to log in:. Address never made public). You are commenting using your WordPress.com account. ( Log Out. You are commenting using your Twitter account. ( Log Out. You are commenting using your Facebook account. ( Log Out. Notify me of new comments via email.
haskell101.wordpress.com
Count matches in a list | Haskell 101
https://haskell101.wordpress.com/2008/02/03/count-matches-in-a-list
February 3, 2008. Count matches in a list. Filed under: Functional programming. 8212; Haskell 101 blogger @ 8:07 pm. What if, instead of just checking to see whether a value exists in a list, we want to count the number of times it is in the list? 1) instances: Int- [Int]- Int. 2) instances x [] = 0. What about if we are evaluating a non-empty list? 3) instances x (y:ys). X= y = 1 (instances x ys). Otherwise = instances x ys. Leave a Comment ». Feed for comments on this post. Leave a Reply Cancel reply.
haskell101.wordpress.com
Welcome to Haskell 101 | Haskell 101
https://haskell101.wordpress.com/2008/01/25/hello-world
January 25, 2008. Welcome to Haskell 101. Filed under: Functional programming. 8212; Haskell 101 blogger @ 4:32 am. Welcome to Haskell 101, a blog where I will walk through my own learnings with the functional programming language known as Haskell. How did I decide to do this? Well, I like to program as a hobby. Of all the languages that I have programmed in (Java, PHP, Visual Basic, and Ruby), Ruby is by far the one I enjoy most. I started to read about the roots of the Ruby programming language.
haskell101.wordpress.com
Our first function | Haskell 101
https://haskell101.wordpress.com/2008/01/26/our-first-function
January 26, 2008. 8212; Haskell 101 blogger @ 4:23 pm. This is known as. I’ll call the function “union.”Let’s set the type signature first. We want to take two lists and return a third. So:. 1) union: [a]- [a]- [a]. How do we define the function? 2) union [] y = y. How about adding each item to the initial list? We’ll cons the item on using the : operator. 3) union (x:xs) y = x:(union xs y). Union: [a]- [a]- [a]. Union [] y = y. Union (x:xs) y = x:(union xs y). Leave a Comment ». Enter your comment here.