Take the first one, please...
-
Consider this very highly anonymized pseudocode. It's a summary of the code I actually read through. I wrote the summary because the real Java has a ton of irrelevant nonsense going on in it, like setting irrelevant variables...
while (rs5.next) # imagine this code is spread out over a 5000 line function... with broken indentation... if(prevId != null && prevId = rs5.getID_PRSN) if(rs5.getCD_ROLEX != RP) if(rs5.getCD_ROLEX not in m_parentRole) # imagine there are 5 of these conditionals, one for each of CD_ROLE1, CD_ROLE2, etc. m_parentRole += rs5.getCD_ROLEX # imagine this is a nicely formatted concat, with commas, etc m_casePart.setTemplateField(m_prevCnt, "p_rolesAdl", m_parentRole) # Note that "p_rolesAdl" is the wrong field ANYWAY continue; # Java semantics... m_parentRole = "" m_role = "" if (rs5.getCD_ROLEX not in [RP, AV, OC]) m_role += rs5.getCD_ROLEX m_parentRole = m_role m_casePart.setTemplateField(m_parentCounter, "p_rolesPrn", m_role) # finally the right field m_prevCnt = m_parentCounter m_prevId = rs5.getID_PRSN
What do we think this does guys? I'll give you a hint: the increasingly poorly described Haskell oneliner looks like:
filter (\x -> not( x `elem` ["AV", "RP", "OC"])) . fmap (^.CD_ROLEX) . join . fmap (take 1) . fmap (sortBy ( \a b -> compare (a ^.CD_ROLEX, b^.CD_ROLEX))) . groupBy (\a b -> a ^. ID_PRSN == b^.ID_PRSN) $ rs5
Oh, and the Java only works if the result set comes in with a specific sort order, which isn't even set in the SQL query.
-
@Captain said in Take the first one, please...:
Oh, and the Java only works if the result set comes in with a specific sort order, which isn't even set in the SQL query.
I believe it is possible to set a default sort order in the DDL, but often people don't (and it isn't good practice).
-
@Captain said in Take the first one, please...:
What do we think this does guys? I'll give you a hint: the increasingly poorly described Haskell oneliner looks like:
A hint in the category of endohints?
-
What do we think this does guys? I'll give you a hint: the increasingly poorly described Haskell oneliner looks like:
. fmap (sortBy ( \a b -> compare (a ^.CD_ROLEX, b^.CD_ROLEX))) . groupBy (\a b -> a ^. ID_PRSN == b^.ID_PRSN)
Detects fake CD_ROLEXes and groups dealers into ID_PRISON?
-
@error Other way around. You group a list into a list of lists (where each sublist has the same prison id), and then sort each sublist on the fake rolex key.