From 27a4f25fb636bbff0f8085d66e433125dc5fe17d Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Thu, 11 Dec 2014 17:26:18 -0500 Subject: [PATCH] Add hope_option:iter/2 --- src/hope.app.src | 2 +- src/hope_option.erl | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hope.app.src b/src/hope.app.src index 3b019ef..89c71bb 100644 --- a/src/hope.app.src +++ b/src/hope.app.src @@ -1,7 +1,7 @@ {application, hope, [ {description, "Higher Order Programming in Erlang"}, - {vsn, "1.1.0"}, + {vsn, "1.2.0"}, {registered, []}, {applications, [ kernel, diff --git a/src/hope_option.erl b/src/hope_option.erl index c461d04..d820b7b 100644 --- a/src/hope_option.erl +++ b/src/hope_option.erl @@ -9,6 +9,7 @@ [ put/2 , get/2 , map/2 + , iter/2 ]). @@ -35,3 +36,8 @@ get(none , Y) -> Y. t(B). map({some, X}, F) -> {some, F(X)}; map(none , _) -> none. + +-spec iter(t(A), fun((A) -> (ok))) -> + ok. +iter({some, X}, F) -> ok = F(X); +iter(none , _) -> ok. -- 2.20.1