It looks like you're new here. If you want to get involved, click one of these buttons!

- All Categories 2.3K
- Chat 495
- Study Groups 6
- Biological Models 1
- Categorical Network Theory 1
- Programming with Categories 4
- Review Sections 6
- MIT 2020: Programming with Categories 53
- MIT 2020: Lectures 21
- MIT 2020: Exercises 25
- MIT 2019: Applied Category Theory 339
- MIT 2019: Lectures 79
- MIT 2019: Exercises 149
- MIT 2019: Chat 50
- UCR ACT Seminar 4
- General 64
- Azimuth Code Project 110
- Statistical methods 2
- Drafts 1
- Math Syntax Demos 15
- Wiki - Latest Changes 0
- Strategy 111
- Azimuth Project 1.1K
- - Spam 1
- News and Information 147
- Azimuth Blog 149
- - Conventions and Policies 21
- - Questions 43
- Azimuth Wiki 708

Options

*Functions in mathematics and Haskell.*

Suppose \(f : Int \to Int \) sends an integer to its square, \(f(x) := x^2 \) and that \(g : Int \to Int \) sends an integer to its successor, \(g(x) := x+ 1\).

(a) Write \(f \) and \(g \) in Haskell, including their type signature and their implementation.

(b) Let \(h := f◦g \). What is \(h(2) \)?

(c) Let \(i := f ; g \). What is \(i(2) \)?

## Comments

My answer: https://paste.sr.ht/~leif/42cc64b988ce44a69dbfc16ab88a0c37237665ba

`My answer: https://paste.sr.ht/%7Eleif/42cc64b988ce44a69dbfc16ab88a0c37237665ba`

what is meant by $f;g$?

`what is meant by $f;g$?`

@HanifBinAriffin: \(f;g\) means apply \(f\), then apply \(g\). It's the opposite order of operations than \(f \circ g\), which means apply \(g\) then \(f\).

In \(f;g\) the data flows "forwards" from left to right (forward only because English reads from left to right), whereas in \(f \circ g\) it flows "backwards" from right to left.

`@HanifBinAriffin: \\(f;g\\) means apply \\(f\\), then apply \\(g\\). It's the opposite order of operations than \\(f \circ g\\), which means apply \\(g\\) then \\(f\\). In \\(f;g\\) the data flows "forwards" from left to right (forward only because English reads from left to right), whereas in \\(f \circ g\\) it flows "backwards" from right to left.`