Skip to content

Instantly share code, notes, and snippets.

View omasanori's full-sized avatar

Masanori Ogino omasanori

View GitHub Profile
@omasanori
omasanori / map.scm
Created February 16, 2014 09:43
A tail-recursive map function with well-known "reverse map" technique.
(define (reverse xs)
(define (rev-iter xs ys)
(if (null? xs)
ys
(rev-iter (cdr xs) (cons (car xs) ys)))) ; tail-recursive
(rev-iter xs '()))
(define (foldl f init xs)
(if (null? xs)
init
(define (reverse xs . args)
(let ((ys (if (not (null? args)) (car args) '())))
(if (null? xs)
ys
(reverse (cdr xs) (cons (car xs) ys)))))
test.c:10:27: warning: incompatible pointer types passing 'jmp_buf' (aka 'struct __jmp_buf_tag [1]') to parameter of type 'void **' [-Wincompatible-pointer-types]
(void)(__builtin_setjmp(tag.buf) ? 1 : 0);
^~~~~~~
1 warning generated.
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/tmp/test-11ca81.o: In function `jump':
test.c:(.text+0x26): undefined reference to `.LBB0_-1'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[ebuild N ~] dev-lang/parrot-6.2.0:0/6.1.0 USE="gdbm gmp nls opengl pcre ssl unicode -doc -examples" 0 kB
[ebuild N ~] dev-lang/nqp-2014.03 USE="parrot -doc -java -moar" 4,929 kB
[ebuild N ~] dev-lang/rakudo-2014.03.01 USE="parrot -doc -java" 1,307 kB
[blocks B ] =dev-lang/parrot-6.2.0 ("=dev-lang/parrot-6.2.0" is blocking dev-lang/nqp-2014.03)
Total: 3 packages (3 new), Size of downloads: 6,235 kB
Conflict: 1 block (1 unsatisfied)
* Error: The above package list contains packages which cannot be
* installed at the same time on the same system.
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
[1 of 1] Compiling Main ( dist/setup/setup.hs, dist/setup/Main.o )
Linking ./dist/setup/setup ...
Configuring purescript-0.5.1...
Building purescript-0.5.1...
Preprocessing library purescript-0.5.1...
[ 1 of 52] Compiling Language.PureScript.Parser.State ( src/Language/PureScript/Parser/State.hs, dist/build/Language/PureScript/Parser/State.o )
[ 2 of 52] Compiling Language.PureScript.CodeGen.Monad ( src/Language/PureScript/CodeGen/Monad.hs, dist/build/Language/PureScript/CodeGen/Monad.o )
$ gcc -E -v -march=native -xc /dev/null 2>&1 | grep cc1
/usr/libexec/gcc/i686-pc-linux-gnu/4.8.3/cc1 -E -quiet -v /dev/null -march=athlon-4 -mno-cx16 -mno-sahf -mno-movbe -mno-aes -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=64 -mtune=athlon -fstack-protector
top: 30
before: 30
top: #<proc 0x7feb29328de0>
before: #<proc 0x7feb29328de0>
top: #<proc 0x7feb29328a20>
before: #<proc 0x7feb29328a20>
top: #<proc 0x7feb2932baf8>
before: #<proc 0x7feb2932baf8>
top: #<proc 0x7feb2932b738>
before: #<proc 0x7feb2932b738>
snippet class
abbr class Class(...): ...
class ${1:Name}(${2:object}):
"""${3:class documentation}"""
def __init__(self, ${4}):
"""${5:__init__ documentation}"""
${6:pass}
snippet def
abbr def function(...): ...
import os, tempfile
t = tempfile.NamedTemporaryFile()
path = os.path.abspath(t.name)
open(path)
--- pit.py.orig 2009-12-22 03:49:04.953125000 +0900
+++ pit.py.added 2009-12-22 03:47:37.671875000 +0900
@@ -18,13 +18,15 @@
else:
if not os.environ.has_key('EDITOR'):
return {}
- t = tempfile.NamedTemporaryFile()
+ t, path = tempfile.mkstemp()
c = yaml.dump(opts['config'] if opts.has_key('config') else Pit.get(name) ,default_flow_style=False)
t.write(c)