# Return to Answer

2 add examples, and counter example

# The ideas in your question are far too difficult, for a one hour introduction.

Yesterday I had a look at Haskell and learnt some. I have over 30 years programming experience (20 years professional). Have experience with functional programming. Yet it took me several hours, and did not get far enough to be able to do your suggestions.

# Mathematics

You say that your students have a maths background.

Take advantage of this. Choose some math problems. That Haskell is ideally suited to solve. And explain why you are doing this.

Ensure that you have more than you think you will need, as some students will be much faster than you expect, but don't expect to use them all.

There are some good ideas here https://stackoverflow.com/a/15110828/537980 also some of the other answers, to the same question: sort, search, interpreter (this one may take too long), factorial.

# Show advantages of functionalAvoid bad examples

Don't do problems that are more difficult in a functional language than in a procedural one (Reversing a list, using procedural techniques, in $$O(n)$$, is easy. If by using functional they will probably get a $$O(n^2)$$ solution, and $$O(n)$$ is hard, then you are teaching a disadvantage on day one.)

Fibonacci is, I think $$O(2^n)$$, for simple recursive implementations.

fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)


I did it in $$O(n)$$ once, that was the day I learnt a lot about caching. It was hard, it took me a whole day.

# The ideas in your question are far too difficult, for a one hour introduction.

Yesterday I had a look at Haskell and learnt some. I have over 30 years programming experience (20 years professional). Have experience with functional programming. Yet it took me several hours, and did not get far enough to be able to do your suggestions.

# Mathematics

You say that your students have a maths background.

Take advantage of this. Choose some math problems. That Haskell is ideally suited to solve. And explain why you are doing this.

Ensure that you have more than you think you will need, as some students will be much faster than you expect, but don't expect to use them all.

# Show advantages of functional

Don't do problems that are more difficult in a functional language than in a procedural one (Reversing a list, using procedural techniques, in $$O(n)$$, is easy. If by using functional they will probably get a $$O(n^2)$$ solution, and $$O(n)$$ is hard, then you are teaching a disadvantage on day one.)

# The ideas in your question are far too difficult, for a one hour introduction.

Yesterday I had a look at Haskell and learnt some. I have over 30 years programming experience (20 years professional). Have experience with functional programming. Yet it took me several hours, and did not get far enough to be able to do your suggestions.

# Mathematics

You say that your students have a maths background.

Take advantage of this. Choose some math problems. That Haskell is ideally suited to solve. And explain why you are doing this.

Ensure that you have more than you think you will need, as some students will be much faster than you expect, but don't expect to use them all.

There are some good ideas here https://stackoverflow.com/a/15110828/537980 also some of the other answers, to the same question: sort, search, interpreter (this one may take too long), factorial.

# Avoid bad examples

Don't do problems that are more difficult in a functional language than in a procedural one (Reversing a list, using procedural techniques, in $$O(n)$$, is easy. If by using functional they will probably get a $$O(n^2)$$ solution, and $$O(n)$$ is hard, then you are teaching a disadvantage on day one.)

Fibonacci is, I think $$O(2^n)$$, for simple recursive implementations.

fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)


I did it in $$O(n)$$ once, that was the day I learnt a lot about caching. It was hard, it took me a whole day.

1

# The ideas in your question are far too difficult, for a one hour introduction.

Yesterday I had a look at Haskell and learnt some. I have over 30 years programming experience (20 years professional). Have experience with functional programming. Yet it took me several hours, and did not get far enough to be able to do your suggestions.

# Mathematics

You say that your students have a maths background.

Take advantage of this. Choose some math problems. That Haskell is ideally suited to solve. And explain why you are doing this.

Ensure that you have more than you think you will need, as some students will be much faster than you expect, but don't expect to use them all.

# Show advantages of functional

Don't do problems that are more difficult in a functional language than in a procedural one (Reversing a list, using procedural techniques, in $$O(n)$$, is easy. If by using functional they will probably get a $$O(n^2)$$ solution, and $$O(n)$$ is hard, then you are teaching a disadvantage on day one.)