Again, nice lecture. I'm lloking forward to the rest.

Here is my take on Append:

public static IEnumerable<T> Append<T>(this IEnumerable<T> a, IEnumerable<T> b) { foreach (var t in a) { yield return t; } foreach (var t in b) { yield return t; } }

{-
1.- What type are the following values:
['a','b','c'] :: [Char]
('a','b','c') :: (Char,Char,Char)
[(False,'0'),(True,'1')] :: [(Bool,Char)]
([False, True],['0','1']) :: ([Bool],[Char])
[tail, init, reverse] :: [[a] -> [a]]
-}
-- 2.- What are the type of the following functions:
second :: [a] -> a
second xs = head (tail xs)
swap :: (a,b) -> (b,a)
swap (x,y) = (y,x)
pair:: a -> b -> (a,b)
pair x y = (x,y)
double :: (Num a) => a -> a
double x = x*2
palindrome :: (Eq a) => [a] -> Bool
palindrome xs = reverse xs == xs
twice :: (a -> a) -> a -> a
twice f x = f (f x)

I think you're missing a great opportunity here. Please ask questions about all the thing that Erik is presenting and you don't understand. I bet you would get a lot of help in the forum. That would help a lot of people that might be having the same issues
as you. Also it would give Erik an inside of what concepts are difficult to grasp and help him to better present future chapters.

Another think hat you can do is read the chapter of the book that Erick is going to present in advance. That way you know what's going to be covered. If you don't have the book, the slides are here:
http://www.cs.nott.ac.uk/~gmh/book.html#slides.

Thanks exoteric. My original solution for init' didn't use composition until I saw the lecture and Erik started talking about function composition (yes, I did the exercises from the book before the lecture ). I'm not sure if good at this point of the
lecture to introduce pointfree style. But how am I to say

This was my original solution:

init’ xs = reverse (tail (reverse xs))

Which I think people not familiar with Haskell would understand better than

init’ = reverse . tail . reverse

I say this, because it took me a while to understand what was going on with the second definition and why the parameter was implicit.

I think you're being too harsh on F#. F# is an excellent bridge for people that want to learn functional programming. I has all the familiar things that an imperative programmer expects like mutable variables, the “for” loop, objects, Visual Studio support.
But once you let go the training wheels, you have access to all the benefits of a functional language.

## Comments

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 6 of 13

More homework:

1) Prove that fac n = recfac n

Definition of recfact n:

(1) recfac 0 = 1

(2) recfac (n+1) = (n+1) * recfact n

Definition of fac n:

(3) fac n = product [1...n]

where

(4) product [] = 1

(5) product [1..n] = 1 * 2 * … (n-1) * n

We want to prove that:

fact n = recfac n

Using induction:

Case n = 0

fac 0 = recfac 0

fac 0 = 1 (Eq. 1)

recfac 0 = product [1 .. 0] = product [] = 1 (Eq. 4)

1 = 1

Case (m + 1):

(7) fac (m+1) = recfac (m+1)

fac (m+1) = product [ 1..(m+1)] = 1 * 2 *….* m * (m+1)

fac (m+1) = 1 * 2 *….* m * (m+1) =(product [1..m]) * (m+1)

(8) fac (m+1) = (product [1..m]) * (m+1)

Using Eq 2 : recfac (m+1) = (m+1) * recfac m

Replacing Eq 8 into Eq 7:

fac (m+1) = (product [1..m]) * (m+1) = recfac (m+1)

Using Eq 2 on the right side:

(product [1..m]) * (m+1) = (m+1) * recfac m

Dividing by (m+1) on both sides:

product [1..m] = recfac m

Using Eq 3 on the left side:

fac m = recfac m

Q.E.D.!

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 6 of 13

Again, nice lecture. I'm lloking forward to the rest.

Here is my take on Append:

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 5 of 13

Here is my take on the homework:

1. Without looking at the definitions from the standard prelude, define the following library functions using recursion.

- Decide if all logical values in a list are True:

- Concatenate a list of lists:

- Produce a list with n identical elements:

- Select the nth element of a list

- Decide if a value is an element of a list:

2. Define a recursive function merge:: Ord a => [a] -> [a] -> [a] that merges two sorted lists to give a single sorted list.

3. Define a recursive function msort :: Ord a => [a] -> [a] that implements merge sort

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 4 of 13

Here is my take on part of the homework

1. safetail

2. Implement (||) in three different ways

3. Redefine (&&)

4. Redefine (&&) again

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 5 of 13

At last Thursday is here.

Excelent presentation as always. The only thing is that you missed an excelent opportunity to implement "where" using a list comprehension.

Thanks again.

I'm looking forward to the next lecture.

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 4 of 13

To get what you want you can use the function flip that is on the haskell prelude.

The Haskell prelude defines flip as:

using flip we can write (-1) 3 as:

Also, the prelude has a substract function defined as:

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 4 of 13

I love the “back to school” feeling I get with these lectures. I like Novox have been waiting all day for this. Keep up the good work

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals, Chapter 3 of 13

Here is part of the homework:

Nice lecture, please keep up the good work!!!

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals, Chapter 3 of 13

I think you're missing a great opportunity here. Please ask questions about all the thing that Erik is presenting and you don't understand. I bet you would get a lot of help in the forum. That would help a lot of people that might be having the same issues as you. Also it would give Erik an inside of what concepts are difficult to grasp and help him to better present future chapters.

Another think hat you can do is read the chapter of the book that Erick is going to present in advance. That way you know what's going to be covered. If you don't have the book, the slides are here: http://www.cs.nott.ac.uk/~gmh/book.html#slides.

I hope this helps.

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals, Chapter 3 of 13

Exelent! I was looking forward to the next lecture.

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals, Chapter 2 of 13

Thanks exoteric. My original solution for init' didn't use composition until I saw the lecture and Erik started talking about function composition (yes, I did the exercises from the book before the lecture ). I'm not sure if good at this point of the lecture to introduce pointfree style. But how am I to say

This was my original solution:

Which I think people not familiar with Haskell would understand better than

I say this, because it took me a while to understand what was going on with the second definition and why the parameter was implicit.

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals, Chapter 2 of 13

I think you're being too harsh on F#. F# is an excellent bridge for people that want to learn functional programming. I has all the familiar things that an imperative programmer expects like mutable variables, the “for” loop, objects, Visual Studio support. But once you let go the training wheels, you have access to all the benefits of a functional language.