eduproj/material/fp-function.yml

31 lines
795 B
YAML

title: Functions
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://tuples
[2]: page://currying
exercises:
- name: doubleIt
description: |
Write a function called `doubleIt` that takes an integer and doubles it.
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));