Jacobi symbol: Difference between revisions
m
→{{header|Haskell}}
(→{{header|Haskell}}: Replaced a do with a (let ... in ...) (No monad used or needed here)) |
|||
Line 275:
import Data.List.Split (chunksOf)
import Data.Bool (bool)
jacobi :: Int -> Int -> Int
jacobi = go
Line 282:
go 0 _ = 0
go x y
| even r =
| otherwise =
where
plusMinus = bool id negate
r = rem x y
-------------------------- TEST ---------------------------
main :: IO ()
main = putStrLn $ jacobiTable 11 9
------------------------- DISPLAY -------------------------
jacobiTable :: Int -> Int -> String
Line 310 ⟶ 311:
(justifyRight w ' ' [] ++ " " ++ unwords (rjust <$> cols)) :
replicate (length $ head rowLines) '-' : rowLines
justifyRight :: Int -> a -> [a] -> [a]
justifyRight n c = (drop . length) <*> (replicate n c ++)</lang>
|