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
<!DOCTYPE html>
<html>
<body>
Hello, world.
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<a href="https://github.com" rel="noopener" target="_blank">link</a>
</body>
</html>
package main
import (
"fmt"
"strings"
"testing"
)
// Version A (traditional)
; 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-darwin16.4.0"
; コード:
; let rec f x = x + x in
; println_int (f 42)
; Function Attrs: nounwind
; 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);
}
}