Skip to content

Instantly share code, notes, and snippets.

View JeffBezanson's full-sized avatar

Jeff Bezanson JeffBezanson

View GitHub Profile
function dispatchratio(D, M::Module, expor, recur)
nspec = 0
nGFspec = 0
for name in names(M,!expor)
if isdefined(M, name)
F = eval(M, name)
if isa(F,Union(Function,DataType))
if isgeneric(F)
if !haskey(D,F)
positions = IntSet()
argtail(x, rest...) = rest
tail(x::Tuple) = argtail(x...)
# x >= y ? t : f
_cmp_ge(x::(), y::(), t, f) = t
_cmp_ge(x::(), y::Tuple, t, f) = f
_cmp_ge(x::Tuple, y::(), t, f) = t
_cmp_ge(x::Tuple, y::Tuple, t, f) = _cmp_ge(tail(x), tail(y), t, f)
# as a string
"function check_new_version(existing::Vector{VersionNumber}, ver::VersionNumber)
@assert issorted(existing)
for v in [v\"0\", v\"0.0.1\", v\"0.1\", v\"1\"]
lowerbound(v) <= ver <= v && return
end
error(\"$ver is not a valid initial version (try 0.0.0, 0.0.1, 0.1 or 1.0)\")
end"
@JeffBezanson
JeffBezanson / escaped-symbols
Last active August 29, 2015 14:03
escaped symbols patch
diff --git a/src/julia-parser.scm b/src/julia-parser.scm
index 549b02f..8949495 100644
--- a/src/julia-parser.scm
+++ b/src/julia-parser.scm
@@ -1677,9 +1677,14 @@
;; symbol/expression quote
((eq? t ':)
(take-token s)
- (if (closing-token? (peek-token s))
- ':
(define (string.rpad s n c) (string s (string.rep c (- n (string.count s)))))
(define (string.rep s k)
(cond ((< k 4)
(cond ((<= k 0) "")
((= k 1) (string s))
((= k 2) (string s s))
(else (string s s s))))
((odd? k) (string s (string.rep s (- k 1))))
(else (string.rep (string s s) (/ k 2)))))
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by arpack-ng configure 3.2.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure --prefix=/home/bezanson/src/julia/usr --build=x86_64-linux-gnu --libdir=/home/bezanson/src/julia/usr/lib F77=gfortran -m64 CC=gcc -m64 CXX=g++ -m64 --with-blas=-L/home/bezanson/src/julia/usr/lib -lopenblas --with-lapack=-L/home/bezanson/src/julia/usr/lib -lopenblas --disable-mpi --enable-shared FFLAGS= -fdefault-integer-8 -cpp -ffixed-line-length-none -Dsaxpy=saxpy_64 -Ddaxpy=daxpy_64 -Dscopy=scopy_64 -Ddcopy=dcopy_64 -Dsgemv=sgemv_64 -Ddgemv=dgemv_64 -Dsgeqr2=sgeqr2_64 -Ddgeqr2=dgeqr2_64 -Dslacpy=slacpy_64 -Ddlacpy=dlacpy_64 -Dslahqr=slahqr_64 -Ddlahqr=dlahqr_64 -Dslanhs=slanhs_64 -Ddlanhs=dlanhs_64 -Dslarnv=slarnv_64 -Ddlarnv=dlarnv_64 -Dslartg=slartg_64 -Ddlartg=dlartg_64 -Dslascl=slascl_64 -Ddlascl=dlascl_64 -Dslaset=slaset_64 -Ddlaset=dla
function factor{T<:Integer}(n::T)
0 < n || error("number to be factored must be positive")
h = Dict{T,Int}()
n == 1 && return h
local s::T, p::T
s = isqrt(n)
p = 2
while p <= s
if n % p == 0
while n % p == 0
@JeffBezanson
JeffBezanson / gist:ea224aa45e2242ca3ee9
Last active August 29, 2015 14:14
simple Dict benchmarks
function stress1(keys::Array{Int,1})
x = Dict{Int,Float64}()
for i in keys
x[i] = 0.0
end
return x
end
function stress_strings(n::Int)
d = Dict{String,Int}()
function rd(f)
nr = countlines(f)::Int
fh = open(f)
nc = length(split(readline(fh),','))
seekstart(fh)
d = Array(Float64, nr, nc)
temp = [0.0]
for i = 1:nr
l = readline(fh)::ASCIIString
idx = 1
index b2b032c..ce89fb3 100644
--- a/extras/tk.jl
+++ b/extras/tk.jl
@@ -92,11 +92,10 @@ type TkWidget
global Window
function Window(title, w, h)
wpath = ".jl_win$ID"; ID += 1
- tcl_eval("frame $wpath -width $w -height $h")
- tcl_eval("wm manage $wpath")
+ tcl_eval("toplevel $wpath -width $w -height $h")