###Talks
This is a list of videos I'd recommend watching.
####Haskell
0 A VUOTO 1 2 VUOTO | |
1 B VUOTO VUOTO 3 0 | |
2 C 0 3 VUOTO VUOTO | |
3 D 1 VUOTO VUOTO 2 |
-- 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 () |
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 |
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 |
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] |
###Talks
This is a list of videos I'd recommend watching.
####Haskell
####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
{-# 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 |
#include <utility> | |
template<class Func, class... Args> | |
auto apply(Func fn, Args&&... args) { | |
return [&](auto&&... sargs) { | |
return fn | |
( std::forward<decltype(args)>(args)... | |
, std::forward<decltype(sargs)>(sargs)... ); | |
}; | |
} |
import qualified Data.Set as Set | |
import System.Random (randomRIO) | |
import Control.Monad (return) | |
type Numbers = Set.Set Int | |
draw :: Int -> Numbers -> IO Numbers | |
draw i s = | |
if ((Set.size s) == i) then return s | |
else do |