eduproj/material/fp-function.yml

46 lines
1.1 KiB
YAML

title: Functions
type: concept
summary: |
Functions describe a process of turning *inputs* into *outputs*.
content: |
In a purely mathematical setting, functions typically have one input and one
output, but in functional programming, we can usually get around this either
by using [tuples][1] or by [currying][2].
[1]: page://fp-tuples
[2]: page://fp-currying
exercises:
- name: doubleIt
style: gradedProgram
description: |
Write a function called `doubleIt` that takes an integer and doubles it.
satisfiesConcept:
- fp-function
graders:
ocaml:
style: studentModule
props:
interface: |
val doubleIt : int -> int
driver: |
open List
let () = List.iter
(fun x -> assert ((doubleIt x) = (x * 2)))
(List.init 100 (fun x -> x + 1));
- name: whichIsFunction
style: multipleChoice
description: |
Which of the following can be described as a _function_?
concepts:
- fp-function
props:
choices:
- foo: bar