Skip to content

Instantly share code, notes, and snippets.

View lucassmagal's full-sized avatar

Lucas S. Magalhães lucassmagal

View GitHub Profile
a = do
x <- [3..4]
[1..2]
return (x, 42)
a = [3..4] >>= \x ->
[1..2] >>= \_ ->
return (x, 42)
module Todotxt where
import Data.List
import Control.Monad
import System.IO
import System.IO.Unsafe
import System.Environment
import System.Directory
foo.bar
import System.IO
import System.IO.Unsafe
import System.Environment
import System.Directory
writeOnFile task = appendFile todoTxt (task ++ "\n")
todoTxt = home ++ "/todo.txt" where
home = unsafePerformIO getHomeDirectory
Int -> Int -> Int
add a b = a + b
Para explicar, vamos trocar os 3 Int por X, Y, e Z, onde a:X, b:Y e c:a+b
X -> Y -> Z
quer dizer que a função recebe dois parâmetros, X e Y, e retorna Z.
Como em Haskell todas as funções são curryied, a expressão acima também quer
dizer que "add" recebe um parâmetro X e retorna *outra função*, que recebe Y
-------------------------------------------------------------------------------
>Log Session: Saturday, March 9, 2013 12:20:25 PM BRT
>System Info:
Product Version = Gephi 0.8.2 201210100934
Operating System = Linux version 3.5.0-25-generic running on amd64
Java; VM; Vendor = 1.7.0_15; OpenJDK 64-Bit Server VM 23.7-b01; Oracle Corporation
Runtime = OpenJDK Runtime Environment 1.7.0_15-b20
Java Home = /usr/lib/jvm/java-7-openjdk-amd64/jre
System Locale; Encoding = pt_BR (gephi); UTF-8
Home Directory = /home/lsmagalhaes
qsort :: (Int -> Int -> Bool) -> [Int] -> [Int]
qsort _ [] = []
qsort fn (pivot:elems) =
let p = filter (fn pivot) elems
q = filter (not . fn pivot) elems
in qsort fn p ++ [pivot] ++ qsort fn q
-- qsort (>) [5,2,6,1,87,0,9]
-- [0,1,2,5,6,9,87]
(function(window, $, undefined) {
'use strict';
// code goes here
})(window, jQuery);
{
"color_scheme": "Packages/Color Scheme - Default/Solarized (Light).tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_face": "Source Code Pro",
"font_size": 12,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Vintage"