thalerjonathan / phd

Stuff of my PhD I want to share publicly: all code, texts of my papers, research-notes & research-diary
GNU General Public License v3.0
30 stars 5 forks source link

Suggestion: simpler expression #2

Closed ivanperez-keera closed 6 years ago

ivanperez-keera commented 6 years ago

The following code:

let mayInf = find (Infected==) aInfs
if isJust mayInf
    then return (Infected, Just ())
    else return (Susceptible, Nothing)

is the same as the simpler:

 if any (Infected ==) aInfs
    then return (Infected,    Just ())
    else return (Susceptible, Nothing)

See: https://github.com/thalerjonathan/phd/blob/d113e8d15e2b524e8169f40bc8cf1e7631d5649e/coding/papers/FrABS/Haskell/SIRDunai/src/Main.hs#L93--L96

EDIT: Moves link below. Adds complete code quote to description.

thalerjonathan commented 6 years ago

Thanks! Have changed it.