From: Mart Lubbers Date: Mon, 28 Sep 2015 15:41:17 +0000 (+0200) Subject: done with ex4 X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=11be36c89c516917dd01b710afcfd6bd6c58ea5d;p=ap2015.git done with ex4 --- diff --git a/a4/mart/skeleton4.icl b/a4/mart/skeleton4.icl index 8ed9269..a521168 100644 --- a/a4/mart/skeleton4.icl +++ b/a4/mart/skeleton4.icl @@ -8,21 +8,28 @@ Pieter Koopman, pieter@cs.ru.nl */ import iTasks +import StdArray // To check string length :: Idea:== String :: Name:== String -:: NamedIdea = { name :: Name, idea :: Idea} +:: NamedIdea = { name :: Name, idea :: [Idea]} derive class iTask NamedIdea // generic magic doIdentified :: (Name -> Task x) -> Task x | iTask x doIdentified task = enterInformation "Enter your name" [] >>= task editIdea :: Name -> Task NamedIdea -editIdea name = enterInformation (name +++ " add your idea") [] +editIdea name = enterInformation (name +++ " add your ideas") [] >>= \idea . return {name = name, idea = idea} -mainTask = doIdentified editIdea >>= viewInformation "The result" [] +mainTask = doIdentified editIdea >>= viewInformation "The result" [ + ViewWith (\x=:{name,idea}.{x & idea=[name:fideas idea]})] + where + //Format the indices and the ideas + fideas i = map (\(x,y).toString (x+1) +++ ": " +++ y) (filt i) + //Filter the ideas on length and add indices + filt i = zip2 (indexList i) (filter (\x.size x > 10) i) Start :: *World -> *World Start world = startEngine mainTask world