Skip to content

Instantly share code, notes, and snippets.

@joneshf
joneshf / vectors.scm
Last active December 17, 2015 17:49
vector intersection
(define (intersect? a b)
(parallel? (vector-product (get-direction a)
(get-direction b))
(vector-product (create-vector (- (get-point a)
(get-point b)))
(get-direction b))))
@joneshf
joneshf / data.json
Last active December 22, 2015 08:09 — forked from viclib/gist:6441678
"perfis":{
"conservador":{
"renda_fixa":{
"percentuais":[70,65,60,55,50,45,40,35,30,25],
"divisao":{
"Renda Fixa Referenciado":100,
"Renda Fixa Índice":0
}
},
"multimercado":{
:- module(booleans, [and/2, or/2]).
:- op(1000, xfy, and).
:- op(1000, xfy, or).
and(P, Q) :- P , Q.
or(P, Q) :- P ; Q.
{-# LANGUAGE FlexibleInstances, FunctionalDependencies, UndecidableInstances #-}
newtype State s a = State (s -> (a, s))
instance Monad (State s) where
return a = State $ \s -> (a, s)
State st >>= f = State $ \s ->
let
@joneshf
joneshf / novo
Created December 8, 2013 00:41
Pacman packages
acpi
acpid
alsa-utils
arch-install-scripts
autoconf
automake
bash
bc
bison
bzip2
add3 = (x, y, z) -> x + y + z
add-three = (x, y, z) --> add3 x, y, z
"""
add3 1 2: #{add3 1 2}
add-three 1 2: #{add-three 1 2}
"""
@joneshf
joneshf / fantasyland.md
Created December 22, 2013 04:59
More inquire garbage.

Terminology

  1. "value" is any JavaScript value, including any which have the structures defined below.
  2. "equivalent" is an appropriate definition of equivalence for the given value. The definition should ensure that the two values can be safely swapped out in a program that respects abstractions. For example:
    • Two lists are equivalent if they are equivalent at all indices.
    • Two plain old JavaScript objects, interpreted as dictionaries, are equivalent when they are equivalent for all keys.
    • Two promises are equivalent when they yield equivalent values.
  • Two functions are equivalent if they yield equivalent outputs for equivalent inputs.
{-# LANGUAGE NoImplicitPrelude #-}
module Simpler where
import Prelude (($), Eq, Show)
import Control.Monad
import Data.Foldable
import Data.Monoid
@joneshf
joneshf / take.hs
Created January 12, 2014 17:38
take
take :: Int -> [a] -> [a]
take n _ | n <= 0 = []
take _ [] = []
take n (x:xs) = x : take (n-1) xs
repeat :: a -> [a]
repeat y = ys where ys = y : ys
take 3 (repeat 1) ~>
-- This evaluates in order of the clauses of take
/**
* Provides a disjoint union of two types.
* A Validation is either <code>Invalid</code> or it is <code>Valid</code>.
*/
public class Validation<Invalid, Valid> {
private Invalid invalid = null;
private Valid valid = null;
// We use a private constructor to ensure that our invariant