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
(defn fact1 [n] | |
(loop [cnt n acc 1] | |
(if (zero? cnt) | |
acc | |
(recur (dec cnt) (* acc cnt))))) | |
(defn fact2 [n] | |
(loop [cnt n acc 1] | |
(do | |
(println cnt acc) |
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
# <License type="Sun Cloud BSD" version="2.2"> | |
# | |
# Copyright (c) 2005-2009, Sun Microsystems, Inc. | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or | |
# without modification, are permitted provided that the following | |
# conditions are met: | |
# | |
# 1. Redistributions of source code must retain the above copyright |
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 Test.Datastore (Datastore, runDatastore, get, put, delete) where | |
import qualified Control.Monad.Reader as R | |
import qualified Database.TokyoCabinet as TC | |
import Control.Monad.Trans (liftIO) | |
import Data.ByteString.Char8 (ByteString) | |
type Key = ByteString | |
type Value = ByteString |
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 Main (main) where | |
import Control.Concurrent (forkIO, threadDelay) | |
import Control.Concurrent.MVar (MVar, modifyMVar_, newMVar, newEmptyMVar, | |
putMVar, takeMVar) | |
import Control.Exception (finally) | |
import Control.Monad (forM_) | |
import qualified IO | |
import IO (BufferMode(..)) |
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
{-# LANGUAGE BangPatterns #-} | |
module Main (main) where | |
import Control.Concurrent (forkIO) | |
import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar) | |
import Control.Exception (finally) | |
import Control.Monad (forM_) | |
import qualified Data.ByteString.Lazy as LB |
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 math | |
import itertools | |
def system(): | |
clock = itertools.count() | |
constant_signal = lambda t: math.sin(t) | |
controllable_signal1 = lambda (a, o): lambda t: a * math.sin((t + o) / 2) | |
controllable_signal2 = lambda (a, o): lambda t: a * math.sin((t + o) * 2) |
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
/* | |
* A "devnull" module | |
* | |
* Cheers @ KDW | |
* | |
* Makefile: | |
* | |
* obj-m := devnull.o | |
* | |
* KERNELDIR ?= /lib/modules/$(shell uname -r)/build |
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
-- This is a snippet cut-and-paste from a larger code body, might not compile or | |
-- work as expected as such | |
import Prelude hiding (pi) | |
import Data.Bits | |
import Data.Word (Word32) | |
import Foreign.C.Types (CSize) | |
import Foreign.Marshal.Array (withArrayLen) |
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
''' | |
A solution for http://www.quora.com/How-to-move-all-negative-numbers-before-positive-numbers-and-preserve-their-original-orders-at-the-same-time-O-n-time-and-O-1-space-are-required | |
''' | |
import operator | |
class Node(object): | |
'''Linked list node representation''' | |
__slots__ = '_data', '_next', |
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
const Clutter = imports.gi.Clutter, | |
ClutterGst = imports.gi.ClutterGst, | |
Gst = imports.gi.Gst, | |
Lang = imports.lang, | |
Mainloop = imports.mainloop; | |
/* Thanks ebassi */ | |
let _animations = new Array(); |