This file contains 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
import Text.Parsec | |
import Text.Parsec.String | |
import Data.List (groupBy, intersperse) | |
-- This is a short example of my file format | |
-- Questions starts with "Q. ", Answers with "A. ". They can span on | |
-- multiple lines and contain inline markup. | |
document :: String | |
document = unlines [ | |
"Q. Question 2.1 can", |
This file contains 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
{- | Parallel computation of IO using applicative style | |
Convert and IO to a Future using *Future*. | |
You can then use applicative style to combine functions over IO and get a result using 'runFuture'. | |
Have a look at '<$.>' and '<*.>' for shortcut to avoid wrapping your io with 'Future'. | |
Exemple: |
This file contains 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
assert True = return () | |
-- code | |
l = words "Hello World. How are you today?" | |
res = words "Hello World. today?" | |
satisfy f predicate x = predicate (f x) | |
main = do | |
assert (filter (\x -> length x > 3) l == res) |
This file contains 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
<?php | |
function print_arr($arr) | |
{ | |
print "["; | |
foreach($arr as $val) | |
{ | |
if(is_array($val)) | |
{ | |
print_arr($val); |
This file contains 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
import numpy | |
import time | |
s = 1000 | |
def monochrome(colors, arr): | |
r, g, b = colors | |
blork = arr[:,:,0] * r + arr[:,:,1] * g + arr[:,:,2] * b | |
return numpy.uint8(blork / (r + g + b)) |
This file contains 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
def stride(n, dims): | |
''' | |
Limitations: | |
- We can go wrong when inverting the order of dimension on | |
input side but not on result side | |
>>> (x, y) = stride(10, (8, 5)) | |
>>> x | |
2 | |
>>> y |
This file contains 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
#include <stdio.h> | |
// A node of the list. | |
struct Node | |
{ | |
struct Node *next; // the next node | |
float value; // the contained value | |
}; | |
// A linked list point to a serie of Node |
This file contains 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
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE TypeApplications #-} | |
module NumberDispath where | |
data Number | |
= DoubleNum !Double |
This file contains 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
On commence par quelques kilos d'extensions : | |
> {-# LANGUAGE GADTs, KindSignatures, DataKinds, TypeFamilies, TypeOperators, | |
> ScopedTypeVariables, FlexibleInstances, ConstraintKinds, PolyKinds, | |
> StandaloneDeriving, NoMonomorphismRestriction #-} | |
> {-# OPTIONS -Wall #-} | |
> module Expr where | |
Et deux trois imports : |
This file contains 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
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
import Data.Type.Equality | |
import Data.Type.Bool | |
import Unsafe.Coerce | |
-- Proof of partial injectivity of (||) | |
-- i.e. |
OlderNewer