This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| definition module Pythagoreans | |
| :: ListTree a = Node a [ListTree a] | |
| primitivePythagoreanTree :: ListTree [Int] | |
| pythagoreans :: ([Int] -> Bool) -> [[Int]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| definition module BinaryTree | |
| :: BinaryTree a = Node a (BinaryTree a) (BinaryTree a) | Leaf | |
| (!!!) infixl 9 :: (BinaryTree a) Int -> a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| definition module PascalsTriangle | |
| pascalsTriangle :: [[BigInt]] | |
| C :: Int Int -> BigInt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| definition module IntegerPartitions | |
| integerPartitions :: Int Int -> [[Int]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| definition module AltEnv | |
| ($) infixr 1 :: (a -> b) a -> b | |
| S :: (a b -> c) (a -> b) a -> c | |
| Y :: (a -> a) -> a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package require Itcl; namespace import ::itcl::* | |
| proc quote arg { string map {& & \" " ' ' < < > >} $arg } | |
| class XmlAttributes { | |
| variable Attributes {} | |
| constructor arg { | |
| dict for {k v} $arg {dict set Attributes $k $v} | |
| } | |
| method configure arg { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Main where | |
| import Data.List.Ordered (union) | |
| main :: IO () | |
| main = print . sum . takeWhile (1000 >) $ union [3,6..] [5,10..] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module main | |
| import StdEnv, StdLib, BigInt | |
| fact :: (Int -> [Int]) | |
| fact = f [2:[3,5..]] where | |
| f [x:xs] n | |
| | n == 1 = [] | |
| | x*x > n = [n] | |
| | n rem x == 0 = [x:f [x:xs] (n/x)] | |
| | otherwise = f xs n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| problem1(Answer) :- aggregate(sum(N),num(N),Answer). | |
| num(N) :- between(1,999,N), answer(N). | |
| answer(N) :- N rem 3 =:= 0, !. | |
| answer(N) :- N rem 5 =:= 0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- use_module(library(primes),[set_primes/1,prime/1,erase_primes/0]). | |
| problem10(Answer) :- | |
| set_primes(2000000), | |
| aggregate(sum(N),prime(N),Answer), | |
| erase_primes. |