From dd0fb673de5f61fc5854762a177a29f0f7db438f Mon Sep 17 00:00:00 2001 From: Alexander James Wallar Date: Tue, 21 Jan 2014 17:31:05 -0500 Subject: [PATCH] Added more functional capabilities --- .../src/com/locaudio/functional/Function.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/app/Locabean/src/com/locaudio/functional/Function.java b/app/Locabean/src/com/locaudio/functional/Function.java index 0be97ab..9635c05 100644 --- a/app/Locabean/src/com/locaudio/functional/Function.java +++ b/app/Locabean/src/com/locaudio/functional/Function.java @@ -1,9 +1,36 @@ package com.locaudio.functional; +import java.util.ArrayList; +import java.util.List; + public abstract class Function { + public abstract R body(T input); - + public R call(T input) { return body(input); } + + public List map( + Function f, IN_TYPE[] inArray) { + + List retList = new ArrayList(); + for (IN_TYPE inVal : inArray) { + retList.add(f.call(inVal)); + } + + return retList; + } + + public List map( + Function f, List inArray) { + + List retList = new ArrayList(); + for (IN_TYPE inVal : inArray) { + retList.add(f.call(inVal)); + } + + return retList; + } + }