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
function A=transclose(A) | |
%returns the transitive closure matrix of the input matrix | |
%input: A(i,j) is 1 if the binary relation if (element i) R (element j) using the %notation in the introduction | |
%of http://en.wikipedia.org/wiki/Transitive_closure | |
% | |
%Usage example: Implements the first example problem on https://www.4clojure.com/problem/84 | |
% | |
%divideskey=[2 3 4 8 9 27]; | |
%%I don't actually use that variable, but it keeps track of what my matrix means | |
% |
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
run ->(e){ p=Hash[*e['QUERY_STRING'].split(/[&=]/)]; [200, {'Content-type'=>'text/html'}, ["Hello #{p['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
# https://gist.github.com/1185131 | |
class Array | |
def next; self[1..-1] end | |
# returns a function that is the combination of a sequence of function calls | |
# on some external arguments. the functions combined are the elements of self. | |
def compose | |
lambda do |*args| | |
inject(*args) do |mem, fn| |
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
#!/bin/env python | |
""" | |
This is a test script to simulate a memcached instance on a server | |
that has gone south and is accepting connections, but generally not | |
responding. | |
The goal of this script is to help test/develop correct client | |
side settings for timeouts/failure scenarios |
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
(def first-n-fib | |
#(loop [l [] a 0 b 1 c 0] | |
(if (= c %) | |
l | |
(recur | |
(conj l a) | |
b | |
(+ a b) | |
(+ 1 c))))) |
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; Copyright (c) Rich Hickey. All rights reserved. | |
; The use and distribution terms for this software are covered by the | |
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php) | |
; which can be found in the file CPL.TXT at the root of this distribution. | |
; By using this software in any fashion, you are agreeing to be bound by | |
; the terms of this license. | |
; You must not remove this notice, or any other, from this software. | |
;dimensions of square world |
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
require 'eventmachine' | |
module Client | |
def connection_completed | |
send_data "*1\r\n$4\r\nPING\r\n" | |
end | |
def receive_data(data) | |
p data | |
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
;; hyone's solution to Longest Increasing Sub-Seq | |
;; https://4clojure.com/problem/53 | |
(fn longest-inc-seq [coll] | |
(reduce #(let [len-a (count %1) | |
len-b (count %2)] | |
(if (and (> len-b 1) (> len-b len-a)) %2 %1)) | |
[] | |
(reductions | |
(fn [xs y] |
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
;; jneira's solution to Transitive Closure | |
;; https://4clojure.com/problem/84 | |
(fn [s] | |
(let [f #(for [[a b] % [c d] % | |
:when (= c b)] [a d])] | |
(->> s (iterate #(let [n (into % (f %))] | |
(when (not= % n) n))) | |
(take-while identity) | |
(last)))) |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Jed Schmidt <http://jed.is> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |