Skip to content

Instantly share code, notes, and snippets.

View marcoonroad's full-sized avatar
🦋
the Future() has been CANCELLED and we .Restart() the DEAD Event[] from the past

Marco Aurélio da Silva marcoonroad

🦋
the Future() has been CANCELLED and we .Restart() the DEAD Event[] from the past
View GitHub Profile
@robotlolita
robotlolita / sum-digits.hm.hs
Last active August 29, 2015 14:00
sum digits in Harmonia
module Fib using: Platform where
open Platform Prelude expose [+, parse, as-string, ~]
open Platform List expose [zip:using:, map:, take:, filter:, sum]
open Platform IO expose [read-line, print]
-- Typing things is currently cumbersome, but the type inference algorithm should catch 90% of this
let (Num a) => String -> a ::
x as-number = x parse
@robotlolita
robotlolita / 0-instructions.md
Last active August 29, 2015 14:00
BECAUSE TYPE SYSTEMS ARE SUPPOSED TO RUN COMPUTATIONS!!1!1!

Write a program in your favourite programming language to compute the sum of the first N even numbers in the Fibonacci sequence, then display the sum of its digits.

E.g.: Where N = 5, the answer is 17, since:

  1. The Fibonacci sequence is 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, ...;
  2. The first 5 even numbers are 0, 2, 8, 34, and 144;
  3. The sum of these numbers is 188;
  4. The sum of the digits of this answer is 17 (1 + 8 + 8).
/*
[DESAFIO / LANGUAGE WAR] Implemente um programa na sua linguagem favorita onde o usuário digita um número x, e o programa calcula o somatório dos x primeiros números pares da sequência fibonacci, e imprime a soma dos algarismos desse número.
Por exemplo, quando x = 5, a resposta é 17, pois:
1. A sequência fibonacci é 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,...
2. Os 5 primeiros números pares são 0, 2, 8 e 34, 144.
3. O somatório disso é 188.
4. Somando os algarismos, 1+8+8 = 17
@SegFaultAX
SegFaultAX / gist:3364849
Created August 16, 2012 00:03
Lua Multimethods (Clojure-style)
function defmulti(keyfn)
if not keyfn then
keyfn = function(...) return ... end
end
local multi = {
_keyfn = keyfn,
_methods = {}
}
setmetatable(multi, {
__call = function(self, ...)
@gmorell
gmorell / gist:8661351
Last active January 4, 2016 18:29 — forked from anonymous/gist:8656123
Crazy processing hexagons, make a bootsplash .zip later.
int[][] result;
float time;
void draw() {
for (int i=0; i<width*height; i++)
for (int a=0; a<3; a++)
result[i][a] = 0;
for (int sa=0; sa<samplesPerFrame; sa++) {
time = map(frameCount-1 + sa*shutterAngle/samplesPerFrame, 0, numFrames, 0, 1);

Is there a user-noticeable difference in how exceptions behave in SML vs OCaml?

Here're a couple of examples demonstrating the generative semantics of SML exceptions (derived from http://mlton.org/GenerativeException) followed by their analogues in OCaml:

1 in SML

@robotlolita
robotlolita / purr.md
Last active May 10, 2017 20:39
Why Purr is awful

You appear to be advocating a new:

  • functional
  • imperative
  • object-oriented
  • procedural
  • stack-based
  • "multi-paradigm"
  • lazy
  • eager
  • statically-typed
@VictorTaelin
VictorTaelin / why.md
Last active August 12, 2017 22:54
What is wrong with the web and why we need Moon (draft)

What is wrong with the web and why we need Moon (draft)

A few days ago, I published an article about Moon, a fundamental building block of a decentralized browser that aims to solve many of Mist's problems. I've showed up some fancy features such as its decentralized package manager and a generalized monadic notation. I guess that made some people angry, wondering why the hell I made yet another programming language when we have so many of them. If you're on that group: you're right. I'm sorry. Believe me when I say I'm as tired of new languages as you, and I'm as pissed with myself as you are. But I'd not have done this if I didn't have a very good reason. Give me, thus, a chance to justify my sins. For one, I didn't actually invent a programming lang

@jschoch
jschoch / stuff.ex
Created April 9, 2015 14:22
struct encoding and decoding nested structs with poison
defmodule MyTime do
defstruct stamp: {0,0,0}
defimpl Poison.Encoder, for: MyTime do
def encode(%MyTime{} = t,options) do
list = Tuple.to_list(t.stamp)
Poison.Encoder.Map.encode(%MyTime{stamp: list},options)
end
end
defimpl Poison.Decoder, for: MyTime do
def decode(s,options) do
defmodule CoreBanking.StructSerializer do
@behaviour EventStore.Serializer
def serialize(x) do
do_serialize(x) |> Poison.encode!
end
def deserialize(x, _opts) do
x |> Poison.decode! |> do_deserialize
end