Skip to content

Instantly share code, notes, and snippets.

julia> foo = 3
3
julia> function test(a::Type{Val{foo}}) return foo end
test (generic function with 2 methods)
julia> test(Val{foo})
3
julia> foo = 4
;; permutations: takes a list and returns a list of lists,
;; where each is a permutation of the original.
;; I got the idea for the algorithm from http://stackoverflow.com/a/23718676/415518.
(define (permutations ls)
(cond
;; base cases: lists of length 0, 1, or 2
[(null? ls) '(())]
[(equal? (length ls) 1) `((,(first ls)))]
[(equal? (length ls) 2)
`((,(first ls) ,(second ls))
nbrs :: G.Graph -> G.Vertex -> [G.Vertex]
nbrs g v =
map snd edgesFromNode where
edgesFromNode = filter (\(v1, _) -> v1 == v) (G.edges g)
import threading
class LVar(object):
def __init__(self):
self.value = 0
def get(self, threshold):
while not self.value >= threshold:
pass
return
(load "mkprelude.scm")
(define peanoo
(lambda (n out)
(conde
[(== n (build-num 0)) (== '(O) out)]
[(fresh (n1 res)
(-o n (build-num 1) n1)
(conso 'S res out)
(peanoo n1 res))])))
trait Printable {
fn print(&self) { println!("{:?}", *self) }
}
impl Printable for int {}
impl Printable for ~str {
fn print(&self) { println(*self) }
}
landin:lvar-examples lkuper$ git reset f550a2
Unstaged changes after reset:
M README.md
M parallel-and.hs
M repeated-write-lvar-max-counter.hs
landin:lvar-examples lkuper$ git st
# On branch master
# Your branch is behind 'origin/master' by 8 commits, and can be fast-forwarded.
# (use "git pull" to update your local branch)
#
landin:haskell lkuper$ ./install_lots.sh --enable-tests
./install_lots.sh: line 22: [: missing `]'
+ OPTS=' -fnewgeneric -fgeneric'
+ '[' -e .cabal-sandbox ']'
+ cabal install -fnewgeneric -fgeneric ./lvish ./par-classes/ ./par-transformers/ ./par-collections/ --enable-tests
Resolving dependencies...
In order, the following will be installed:
par-classes-1.0.1 (reinstall)
par-collections-1.0 *test (reinstall) changes: HUnit-1.2.5.2 added,
atomic-primops-0.4 added, monad-par-0.3.4.6 added, test-framework-0.8 added,
landin:lvish lkuper$ cabal test
Re-configuring with test suites enabled. If this fails, please run configure
manually.
Resolving dependencies...
Configuring lvish-1.1.0.3...
Building lvish-1.1.0.3...
Preprocessing library lvish-1.1.0.3...
Control/LVish/SchedIdempotentInternal.hs:33:0:
warning: #warning "Compiling with non-scalable deque."
Last login: Thu Dec 12 12:09:00 on console
landin:~ lkuper$ cd repos/lvars/
landin:lvars lkuper$ git pull
remote: Counting objects: 972, done.
remote: Compressing objects: 100% (494/494), done.
remote: Total 790 (delta 448), reused 598 (delta 258)
Receiving objects: 100% (790/790), 187.72 KiB, done.
Resolving deltas: 100% (448/448), completed with 51 local objects.
From github.com:iu-parfunc/lvars
abeb337..26082c1 master -> origin/master