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]
View standard.md

Recurrent Standard C++ quotes

This is a list of quotes from the C++ standard that are often useful while answering questions on StackOverflow. Feel free to suggest quotes that should be added.

The following quotes refer to the N3936 draft (~C++14).


§1.9/15 Program execution [intro.execution]

Except where noted, evaluations of operands of individual operators and of subexpressions of individual expressions are unsequenced. [ Note: In an expression that is evaluated more than once during the execution of a program, unsequenced and indeterminately sequenced evaluations of its subexpressions need not be performed consistently in different evaluations. — end note ] The value computations of the operands of an operator are sequenced before the value computation of the result of the operator. If a side effect on a scalar object is unsequenced relative to either another side effect on the same scalar object or a value computatio

View renderable.hs
1 2 3 4 5 6 7 8 9 10
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverlappingInstances #-}
{-# LANGUAGE UndecidableInstances #-}
 
import Data.Map (Map)
import Data.List (intersperse)
import qualified Data.Map as Map
 
class Renderable a where
render :: a -> String
Something went wrong with that request. Please try again.