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
-- Could use a few rounds of cleanup... | |
import Data.Char | |
import Data.List | |
dictionary :: [String] | |
dictionary = [[chr c] | c <- [0 .. 127]] | |
prefixes :: [String] -> String -> [(Int, String)] | |
prefixes xs y = [(i, xs !! i) | i <- [0 .. (length xs) -1], xs !! i `isPrefixOf` 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
;; regex to match cyrillic words | |
;; регулярное выражение для кириллического текста | |
(defn get-words [text] (re-seq #"[\p{IsCyrillic}\p{N}]+" text)) | |
(def my-text "Переходите сюда, chere Helene, [милая Элен,] – сказала Анна Павловна красавице княжне, которая сидела поодаль, составляя центр другого кружка.") | |
(println (get-words my-text)) | |
; (Переходите сюда милая Элен сказала Анна Павловна красавице княжне которая сидела поодаль составляя центр другого кружка) |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(function() { | |
window.WebSocket = window.WebSocket || window.MozWebSocket; | |
var websocket = new WebSocket('ws://127.0.0.1:9000', |
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
; -> ->> -<> -<>> for S7 Scheme | |
; inspired by https://github.com/nightfly19/cl-arrows and https://github.com/rplevy/swiss-arrows | |
(require stuff.scm) | |
; using: any? while | |
; replace those with your favorite scheme alternatives | |
; direct translation from https://github.com/nightfly19/cl-arrows | |
(define (arrow-proto handler initial-form forms) | |
(let ((output-form initial-form) |
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 OverloadedStrings #-} | |
module SimpleThings where | |
import Control.Applicative ((<$>), (<*>)) | |
import Control.Monad (mzero) | |
import Data.Aeson | |
import qualified Data.Aeson as A | |
-- | sum type containing all possible payloads |
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 CPP, FlexibleContexts, BangPatterns #-} | |
module Control.Concurrent.ThreadPool ( | |
createPool | |
, destroyPool | |
, withPool | |
, pushWork | |
, popResult | |
, popResult' |
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
/* | |
Example of a C program embedding ECL with callbacks to C functions. | |
Compiled via: gcc ecldemo.c -lecl | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include "ecl/ecl.h" | |
#define DEFUN(name,fun,args) \ | |
cl_def_c_function(c_string_to_object(name), \ |
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
-- solution to Haskell kata | |
-- https://www.codewars.com/kumite/new?group_id=5463fbb024b6c287a0000016&review_id=5463fbb024b6c287a0000014 | |
module IPv4 where | |
import Data.List (intercalate) | |
import Data.Word (Word32) | |
import Data.Int (Int32) | |
import Data.Bits ((.&.), shiftR) | |
type IPString = String |
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
// Not quite as bad as https://twitter.com/ivansafrin/status/457248037157740544 but still hairy. | |
#include <memory> | |
#include <type_traits> | |
#include <iostream> | |
template <typename Creator, typename Destructor, typename... Arguments> | |
auto make_resource(Creator c, Destructor d, Arguments &&... args) { | |
using value_t = typename std::decay<decltype(*c(std::forward<Arguments>(args)...))>::type; | |
using ptr_t = std::unique_ptr<value_t, void (*)(value_t *)>; |
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 Random | |
import Mouse | |
import Graphics.Collage exposing (toForm, move, collage) | |
import Graphics.Element exposing (show) | |
import List exposing (..) | |
import Time | |
type Fruit = Apple | Orange | Banana | Melon | Guava | |
-- For module global declarations, it is often helpful to |