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(dplyr) # version 0.4.3 | |
f1 <- function(x, y) { if (x < 5) y else if (x >= 5) y + 10 } | |
f2 <- function(x, y) { if (x < 5) y + 0 else if (x >= 5) y + 10 } | |
d <- data.frame(x=1:10, y=1:10) | |
d %>% rowwise() %>% mutate(z=f1(x, y)) | |
# Error: incompatible types, expecting a integer vector | |
d %>% rowwise() %>% mutate(z=f2(x, y)) | |
# Source: local data frame [10 x 3] | |
# Groups: <by row> |
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 decorator(f): | |
def f_new(): | |
print "pre" | |
f() | |
print "post" | |
try: | |
f.decorated | |
return f | |
except AttributeError: | |
f_new.decorated=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
def decorator(fn): | |
def f(): | |
return "dec" + fn() | |
f.decorated=True | |
f.original_func = fn | |
return f | |
def decorator_override(fn): | |
def f(): | |
if fn.decorated: |
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 fact [n] | |
(cond (zero? n) 1 | |
:else (* n (fact (dec n)) ))) | |
(defn fact-tail [n] | |
(loop [n n acc 1] | |
(cond (zero? n) acc | |
:else (recur (dec n) (* acc n))))) |
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
file looks like this: | |
; ras/test.tim | |
(ns ras.test) | |
; here's the error: | |
; Error detected while processing function timl#loader#source..timl#compiler#build..<SNR>95_emit..timl#call..150..timl#type#apply..timl#lazy_seq#seq..<SNR>97_val..timl#call..289..<SNR>72_predicate | |
..timl#coll#chunked_seqp: |
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 | |
import Image, ImageTk | |
im = Image.open('pic.bmp') | |
root = Tkinter.Tk() | |
dither8 = [[ 0, 32, 8, 40, 2, 34, 10, 42], | |
[48, 16, 56, 24, 50, 18, 58, 26], | |
[12, 44, 4, 36, 14, 46, 6, 38], | |
[60, 28, 52, 20, 62, 30, 54, 22], | |
[ 3, 35, 11, 43, 1, 33, 9, 41], |
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 rhizome-fun.core | |
; [rhizome "0.2.0"] | |
(:require [rhizome.viz :refer [view-graph save-graph]])) | |
(def alpha-nodes (mapv (comp keyword str) | |
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")) | |
(defn random-from [nodes] | |
(let [n (rand-int (count nodes)) | |
pick (nodes n) |
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 'package) | |
(setq package-archives | |
'(("marmalade" . "http://marmalade-repo.org/packages/"))) | |
(package-initialize) | |
(mapc | |
(lambda (package) | |
(or (package-installed-p package) | |
(if (y-or-n-p (format "Package %s is missing. Install it? " package)) | |
(package-install package)))) |
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 clj-async-tests.core | |
(:require [clojure.core.async :as async | |
:refer [go chan >! <! >!! <!! timeout close! thread alts! alts!!]])) | |
(defn walk [t] | |
(cond (nil? t) | |
nil | |
:else | |
(let [[l v r] t] | |
(concat (walk l) [v] (walk r))))) |
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! s:repl.includes_file(file) dict abort | |
let is_zipfile = matchstr(a:file, '\C^zipfile:.*::') | |
let is_fugitive = matchstr(a:file, '\C^fugitive:\/\/.*') | |
if !empty(is_zipfile) | |
let file = substitute(a:file, '\C^zipfile:\(.*\)::', '\1/', '') | |
elseif !empty(is_fugitive) | |
let file = substitute(a:file, '\C^fugitive:\/\/\(.*\)', '\1', '') | |
let file = substitute(file, '\/\.git\/\/[^\/]\+', '', '') | |
else | |
let file = a:file |
NewerOlder