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
| (ns kleene) | |
| ;; | |
| ;; Inspired by "Regexes, Kleene Algebras and Real Ultimate Power" | |
| ;; http://plastic-idolatry.com/erik/oslo2014.pdf | |
| ;; | |
| ;; What do we want to do?... | |
| ;; | |
| ;; (def p1 (times (Var. "w") (Var. "o") (Var. "w")) | |
| ;; (matches? p1 "wow") ;; true |
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
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| "math/rand" | |
| ) | |
| const ( | |
| CUTTING_TIME = 20 |
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
| import scala.actors.Actor | |
| import scala.actors.Actor._ | |
| case object Ping | |
| case object Pong | |
| case object Stop | |
| class Ping(count: Int, pong: Actor) extends Actor { | |
| def act() { | |
| var pingsLeft = count - 1 |
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
| %% | |
| %% Solve sleeping barber problem in most general case | |
| %% Task description on Wikipedia: | |
| %% http://en.wikipedia.org/wiki/Sleeping_barber_problem | |
| %% | |
| %% Additions to classic variant: | |
| %% * many barbers | |
| %% * many clients generators with random timeouts between clients | |
| %% * calculation for total served clients | |
| %% * random time for each client to make barber's job |
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
| %% | |
| %% Solve sleeping barber problem in most general case | |
| %% Task description on Wikipedia: | |
| %% http://en.wikipedia.org/wiki/Sleeping_barber_problem | |
| %% | |
| %% Additions to classic variant: | |
| %% * many barbers | |
| %% * many clients generators with random timeouts between clients | |
| %% * calculation for total served clients | |
| %% * random time for each client to make barber's job |
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
| %% | |
| %% Solve sleeping barber problem in most general case | |
| %% Task description on Wikipedia: | |
| %% http://en.wikipedia.org/wiki/Sleeping_barber_problem | |
| %% | |
| %% Additions to classic variant: | |
| %% * many barbers | |
| %% * many clients generators with random timeouts between clients | |
| %% * calculation for total served clients | |
| %% * random time for each client to make barber's job |
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
| import Data.List | |
| uniqSubstr :: String -> Int | |
| uniqSubstr = sum . (map pair) . pairwise . sort . tails | |
| where | |
| pairwise l@(_:ht) = zip l ht | |
| prefix pre post = length $ takeWhile (uncurry (==)) $ zip pre post | |
| pair (pre, post) = length $ drop (prefix pre post) post |
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
| import Tkinter as tk | |
| import time | |
| from operator import itemgetter | |
| from math import sqrt | |
| from random import randint | |
| from Queue import Queue | |
| from threading import Thread | |
| def vdist(q, (x1,y1), (x2,y2)): |
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
| #lang racket/base | |
| (require data/queue) | |
| (provide fork yield done run-threads) | |
| (define current-runqueue (make-parameter #f)) | |
| (define (fork thunk) | |
| (enqueue! (current-runqueue) (lambda () (thunk) (done)))) | |
| (define (yield) |
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
| import Pipes | |
| # defservice Profile do ... end | |
| # defservice Device do ... end | |
| # defservice Push do ... end | |
| send = pipe do | |
| profile <- Profile.all &1 | |
| badge <- Profile.get_badge_size profile | |
| device <- Device.sessions profile |
OlderNewer