From 11be36c89c516917dd01b710afcfd6bd6c58ea5d Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Mon, 28 Sep 2015 17:41:17 +0200 Subject: [PATCH] done with ex4 --- a4/mart/skeleton4.icl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 -- 2.20.1