View gist:d43507abfb86622c79a2
1 2 3 4 5 6 7 8 9 10
{-| Class that represents an object that can be updated
every x amount of time (where x is fixed). |-}
class Mutable t where
update :: t -> Engine t
updateRate :: UPS
 
{-| Class representing an object that changes when
an user performs input operations. |-}
class Reactive t where
react :: Input -> t -> Engine t
View model.pm
1 2 3 4 5 6 7 8 9 10
use strict;
use warnings;
use XML::LibXML;
 
package Model {
 
# Factory class method that
# builds a model from an XML node.
sub _from_node {
my $class = shift;
View rest.hs
1 2 3 4 5 6 7 8 9 10
{-# LANGUAGE TypeFamilies, FlexibleInstances #-}
 
module Main where
 
-- API
class Referenceable a where
type ReferenceType a :: *
expand :: ReferenceType a -> IO a
 
-- Post & posts example
View PuzzleGenerator.hs
1 2 3 4 5 6 7 8 9 10
module Main where
 
import Prelude hiding (id)
import Data.List (intersperse)
import System.Random
import Control.Applicative
 
type PieceId = String
type PieceContent = Char
View ExampleInput.txt
1 2 3 4
0 A VUOTO 1 2 VUOTO
1 B VUOTO VUOTO 3 0
2 C 0 3 VUOTO VUOTO
3 D 1 VUOTO VUOTO 2
View perms.hs
1 2 3 4 5 6 7 8 9 10
-- Original question can be found here:
-- http://www.reddit.com/r/haskell/comments/2lq8dt/produce_infinite_list_with_a_string/
 
permWithRep :: Int -> [a] -> [[a]]
permWithRep = replicateM
 
allSets :: String -> [[String]]
allSets str = map (flip permWithRep $ str) [0..]
 
main :: IO ()
View pangram.hs
1 2 3 4 5 6 7 8 9 10
import Data.Char (toLower)
 
isPangram :: String -> Bool
isPangram s =
let ls = map (toLower) s
in null . filter (not . (`elem` ls)) $ ['a'..'z']
 
main :: IO ()
main = do
s <- getLine
View at_least_two_equal_digits.hs
1 2 3 4 5 6 7 8 9 10
import Data.Map (Map)
import qualified Data.Map as Map
 
countDistinct :: Ord a => [a] -> Int
countDistinct = Map.size . foldr fn Map.empty
where fn e = Map.insertWith (+) e 1
 
validStrings :: [String]
validStrings =
filter ((`elem` [1..3]) . countDistinct) $ do
View matrix_fun.hs
1 2 3 4 5 6 7 8 9
data Matrix a
= Matrix (Int, Int) [[a]]
deriving (Eq, Show)
rowIndexes :: Matrix a -> [Int]
rowIndexes (Matrix (_, y) _) = [0..y - 1]
 
colIndexes :: Matrix a -> [Int]
colIndexes (Matrix (x, _) _) = [0..x - 1]
Something went wrong with that request. Please try again.