Jacobi symbol: Difference between revisions

Content deleted Content added
Hout (talk | contribs)
m →‎{{header|Haskell}}: Disaggregated the tabulation functions a little
Hout (talk | contribs)
Line 290:
 
------------------------- DISPLAY -------------------------
 
jacobiTable :: Int -> Int -> String
jacobiTable nCols nRows =
labelledRowslet (fmaprowLabels show= [1,3 .. (2 * nRows)]) $
withColumnLabels ("" : fmap show [0 .. nCols]) $
colLabels = [0 .. pred nCols]
labelledRows (fmap show [1,3 .. (2 * nRows)]) $
in withColumnLabels ("" : fmap show [0 .. nCols]colLabels) $
paddedCols $
labelledRows (fmap show rowLabels) $
chunksOf nRows $
paddedCols $
uncurry jacobi <$> ((,) <$> [0 .. pred nCols] <*> [1,3 .. (nRows * 2)])
chunksOf nRows $
 
uncurry jacobi <$> ((,) <$> [0 .. pred nCols]colLabels <*> [1,3 .. (nRows * 2)]rowLabels)
 
-------------------------- TEST ---------------------------
main :: IO ()
main = putStrLn $ jacobiTable 11 9
 
 
 
------------------ TABULATION FUNCTIONS -------------------
paddedCols
 
paddedCols :: Show a => [[a]] -> [[String]]
=> [[a]] -> [[String]]
paddedCols cols =
let scols = fmap show <$> cols