Skip to content

Instantly share code, notes, and snippets.

View rhysd's full-sized avatar
🐕
Fixing an off-by-wan error

Linda_pp rhysd

🐕
Fixing an off-by-wan error
View GitHub Profile
; ModuleID = 'foo.c'
source_filename = "foo.c"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.12.0"
@.str = private unnamed_addr constant [13 x i8] c"hello, world\00", align 1
; Function Attrs: nounwind ssp uwtable
define i32 @main() #0 {
%1 = alloca i32, align 4
let rec fact_ i acc = if i = 0 then acc else fact_ (i-1) (i+acc) in
let rec fact i = fact_ i 0 in
println_int (fact x)
; ModuleID = 'foo.ml'
source_filename = "foo.ml"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-darwin15.6.0"
declare void @println_bool(i1) #0
; Function Attrs: ssp uwtable
define i32 @main() #1 {
entry:
@rhysd
rhysd / 0これが.ml
Last active February 15, 2017 09:58
変遷の様子
let a = 10 in
let rec f x = if x < 1 then 0 else x + (f (x - 1)) in
print_int (f a)
package lexer
import (
"bufio"
"bytes"
"fmt"
"github.com/rhysd/mincaml-parser/token"
"io"
"unicode"
"unicode/utf8"
pub fn insert(target: &mut String, index: usize, replaced: &str) {
for c in replaced.chars().rev() {
target.insert(index, c);
}
}
function peco-repos() {
local input
input="$(find "$GOPATH/src" -maxdepth 3 -mindepth 3 -name "*" -type d)"
input="${input}\n$(ghq list | sed "s#^#$(ghq root)/#")"
input="${input}\n$(ls -1 -d "$HOME/.vim/bundle/"*)"
input="${input}\n$(ls -1 -d "$HOME/.cache/dein/repos/"*)"
input="$(echo "$input" | sed "s#^$HOME#~#g")"
local selected_dir=$(echo "${input}" | peco --prompt 'repos >' --query "$LBUFFER")
diff --git a/target/elc.c b/target/elc.c
index 80b08c9..030a5f8 100644
--- a/target/elc.c
+++ b/target/elc.c
@@ -12,6 +12,7 @@ void target_js(Module* module);
void target_php(Module* module);
void target_el(Module* module);
void target_vim(Module* module);
+void target_viml(Module* module);
void target_tex(Module* module);
@rhysd
rhysd / foo.d.ts
Last active November 22, 2016 11:10
/// <reference types="node" />
import * as stream from 'stream';
export declare default function hogehoge(): stream.Transform;
@rhysd
rhysd / foo.vim
Last active November 19, 2016 17:02
function! s:fold(list, init, pred) abort
let acc = a:init
for item in a:list
let acc = a:pred(acc, item)
endfor
return acc
endfunction
echo s:fold([1, 2, 3, 4, 5], 0, {acc, i -> acc + i})