This file contains hidden or 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
// José's proposition | |
{ :suspended, n_, cont } = Enumerable.reduce(1..5, { :cont, 0 }, fn x, n -> | |
if x == 3 do | |
{ :suspend, n } | |
else | |
{ :cont, n + x } | |
end | |
end) |
This file contains hidden or 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
defmodule Seqable do | |
defprotocol ChuckNorris do | |
def value?(continuation) | |
def value(continuation) | |
def next(continuation) | |
end | |
defimpl ChuckNorris, for: List do | |
def value?([]), do: false |
This file contains hidden or 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
using System.IO; | |
using System; | |
using System.Linq; | |
public class Anagram | |
{ | |
// I am aware about, but have no intention on using | |
// `string.Equals(a, b, StringComparison.OrdinalIgnoreCase)` | |
// as that is longer | |
public static string[] Detect(string subject, string[] Candidates) |
This file contains hidden or 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
myLength :: (Num a) => [t] -> a | |
myLength [] = 0 | |
myLength (_:xs) = 1 + myLength xs | |
mySum :: (Num a) => [a] -> a | |
mySum [] = 0 | |
mySum (x:xs) = x + (mySum xs) | |
mean :: Fractional a => [a] -> Maybe a |
This file contains hidden or 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
; taken from http://elegantcode.com/2013/12/19/clojure-kata-1-fizz-buzz/ | |
(defn fizz-buzz [number] | |
(let [fizz? (zero? (rem number 3)) | |
buzz? (zero? (rem number 5)) | |
fizz-buzz? (and fizz? buzz?)] | |
(cond | |
fizz-buzz? "fizzbuzz" | |
fizz? "fizz" | |
buzz? "buzz" | |
:else number))) |
This file contains hidden or 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
from selenium import webdriver | |
import os | |
import subprocess | |
def before_all(context): | |
get_browser(context) | |
get_sut_url(context) | |
def after_all(context): |
This file contains hidden or 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
module InventoryItems(Command(..), Event(..), handle) where | |
import Data.Maybe(isJust) | |
type Id = String | |
type Name = String | |
type Amount = Int | |
data Command = CreateInventoryItem Id | |
| RenameInventoryItem Id Name |
This file contains hidden or 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
# FoundationDB Python API | |
# Copyright (c) 2012 FoundationDB, LLC | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
This file contains hidden or 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
[root@ghcwebcurrent bench]# ghc --version | |
The Glorious Glasgow Haskell Compilation System, version 7.4.2 | |
[root@ghcwebcurrent bench]# bench 5 aaa & | |
[1] 537 | |
[root@ghcwebcurrent bench]# weighttp -t 2 -n 100000 -c 100 127.0.0.1:8000/ | |
weighttp - a lightweight and simple webserver benchmarking tool | |
starting benchmark... | |
spawning thread #1: 50 concurrent requests, 50000 total requests | |
spawning thread #2: 50 concurrent requests, 50000 total requests |
This file contains hidden or 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
static ERL_NIF_TERM nif_fdb_future_get_keyvalue_array(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) | |
{ | |
enif_future_t *f; | |
const FDBKeyValue * out_kv=NULL; | |
int out_count = 0; | |
fdb_bool_t out_more = 0; | |
if (argc!=1) return enif_make_badarg(env); | |
if (get_future(env, argv[0], &f) == 0 ) | |
return enif_make_badarg(env); |