eduproj/material/fp-function.yml

31 lines
795 B
YAML
Raw Normal View History

2021-08-28 10:52:47 +00:00
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:
2021-08-28 18:03:38 +00:00
- name: doubleIt
description: |
2021-08-28 10:52:47 +00:00
Write a function called `doubleIt` that takes an integer and doubles it.
2021-08-28 18:03:38 +00:00
graders:
2021-08-28 10:52:47 +00:00
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));