Please enable JavaScript or upgrade your browser.
{- | ____|| _ \ | ____| / _____|| ____| | |__ | |_) | | |__ | | __ | |__ | __| | | __| | | |_ | | __| | | | |\ \__ | |____ | |__| | | |____ |__| | _| `.___||_______| \______| |_______| ************ A Haskell for the JVM ************* Here in the editor, you can edit Frege code and then run it by clicking the 'Evaluate' button at the bottom or by pressing 'Ctrl + Enter'. Try the lines below or find more inspiration under https://github.com/Frege/frege/wiki/Online-REPL-Walkthrough -} module examples.NumbersExample where --- Return a list of all factors of 'n' paired up. factors n = [ (x, y) | -- make pairs of x and y, where x <- [1..n], -- x's are drawn from a list of 1 to n y <- [1..x], -- y's are drawn from a list of 1 to x (!) x * y == n -- filter where x and y are pairwise factors ] isPrime n = factors n == [(n,1)] allPrimes = filter isPrime [1..] {- Evaluate and then try these lines in the repl :browse NumbersExample factors 1729 isPrime 11 allPrimes :set show-limit 200 allPrimes -}
Walk through examples