Tessmore / gr_v4

Software engineering group V4 repository
0 stars 0 forks source link

Week 4: if you have read this and you have no questions, please close this issue. #1

Open BertLisser opened 11 years ago

BertLisser commented 11 years ago

Opg 5

-- Haskell has built in isTransitive
-- isTransitive r = and [((x `po` y) && (y `po` z)) `implies` (x `po` z) | x <- set, y <- set, z <- set]
--testTrClos1 = isTransitive (trClos [(1,1), (1,2), (1,3), (2,3), (3,1)])

Where do you find this en why didn't you use this? However the definition of isTransitive is very nice.

Opg 4

trClos :: Ord a => Rel a -> Rel a
trClos r = nub (trClosHelper (trClosHelper r))

trClosHelper :: Ord a => Rel a -> Rel a
trClosHelper [] = []
trClosHelper (x:xs) = x : ([x] @@ xs) ++ trClos xs

is OK, but the definition can be shorter and more optimal (even an one liner).

Tessmore commented 11 years ago

Hello BertLisser,

All built in Haskell functions can be found in the documentation: For example: http://hackage.haskell.org/package/HaskellForMaths-0.4.5/docs/src/Math-Combinatorics-Poset.html#isTransitive

For the trClosHelper, since we use the @@ it could never be a one-liner right? As that is already 3 lines on its own. Or what exactly do you mean?

BertLisser commented 11 years ago

All built in Haskell functions can be found in the documentation: For example: http://hackage.haskell.org/package/HaskellForMaths-0.4.5/docs/src/Math-Combinatorics-Poset.html#isTransitive Thank you for the tip. But why didn't you use this. For the trClosHelper, since we use the @@ it could never be a one-liner right? As that is already 3 lines on its own. Or what exactly do you mean?

I mean for example this: trClos :: Ord a => Rel a -> Rel a trClos x = lfp (\ x -> nub (x ++ (x @@ x))) x

I admit that this solution requires a lot of experience in functional programming.

Kind Regards

   Bert

----- Original Message ----- From: "Tessmore" notifications@github.com To: "Tessmore/gr_v4" gr_v4@noreply.github.com Cc: "BertLisser" Bert.Lisser@cwi.nl Sent: Saturday, October 5, 2013 5:45:15 PM Subject: Re: [gr_v4] Week 4: if you have read this and you have no questions, please close this issue. (#1)

Hello BertLisser,

For the trClosHelper, since we use the @@ it could never be a one-liner right? As that is already 3 lines on its own. Or what exactly do you mean?


Reply to this email directly or view it on GitHub: https://github.com/Tessmore/gr_v4/issues/1#issuecomment-25750846

Tessmore commented 11 years ago

Thanks. I will look into it!