From 5e6ad51844bba20a9f51fa4c2aad3d1545f8a039 Mon Sep 17 00:00:00 2001 From: tiago Date: Wed, 21 Dec 2022 23:08:43 +0000 Subject: [PATCH] Problema 3 parte um feita, monads go brrr --- cp2223t/cp2223t.lhs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cp2223t/cp2223t.lhs b/cp2223t/cp2223t.lhs index 24c43c3..b6aeaec 100644 --- a/cp2223t/cp2223t.lhs +++ b/cp2223t/cp2223t.lhs @@ -159,7 +159,7 @@ \begin{center}\large \begin{tabular}{ll} -Grupo nr. & 99 (preencher) +Grupo nr. & 51 \\\hline a93248 & João Tiago Alves Fidalgo de Sousa \end{tabular} @@ -1187,11 +1187,26 @@ Analisando melhor o gene do catamorfismo \begin{code} squares = anaRose gsq -gsq = undefined +gsq = (either (id >< nil) (split p1 surrounding_squares)) . distr . (center_square >< outNat) + +center_square = add_side_to_x . add_side_to_y . (id >< (/3)) + +surrounding_squares = rstr . ((conc . split top_squares (conc . split middle_squares bottom_squares)) >< id) + +top_squares = cons . split sub_side_to_x (cons . split id (singl . add_side_to_x)) . add_side_to_y +middle_squares = cons . split sub_side_to_x (singl . add_side_to_x) +bottom_squares = cons . split sub_side_to_x (cons . split id (singl . add_side_to_x)) . sub_side_to_y + +add_side_to_x = split (split (uncurry (+) . (p1 >< id)) (p2 . p1)) p2 +add_side_to_y = split (split (p1 . p1) (uncurry (+) . (p2 >< id))) p2 +sub_side_to_x = split (split (uncurry (-) . (p1 >< id)) (p2 . p1)) p2 +sub_side_to_y = split (split (p1 . p1) (uncurry (-) . (p2 >< id))) p2 + + rose2List = cataRose gr2l -gr2l = undefined +gr2l = cons . (id >< concat) carpets = undefined