Skip to content

Instantly share code, notes, and snippets.

View zero.fth
: 0 ." This is 1." 1 cr ;
: 𝟶 ." This is 2." 2 cr ;
: 𝟢 ." This is 3." 3 cr ;
0 . cr
𝟶 . cr
𝟢 . cr
@yshl
yshl / aaa_parser.rb
Last active May 15, 2016
パーサーの練習
View aaa_parser.rb
#!/usr/bin/ruby
require 'parslet'
class AAAParser < Parslet::Parser
root :all
rule(:all){
# 全体は line の 0 回以上の繰り返しの後に
line.repeat >>
# statement があるかもしれない
statement.maybe
@yshl
yshl / crc32quine.c
Last active Aug 29, 2015
Search CRC-32 Quine
View crc32quine.c
#include<stdio.h>
#include<stdint.h>
#ifdef CAPITAL
#define CHAR_A 'A'
#define FORMAT "%08X\n"
#else
#define CHAR_A 'a'
#define FORMAT "%08x\n"
#endif
View Makefile
CC=gcc
CFLAGS=-Wall -g -O2
all: ping
ping: ping.o
$(CC) $(CFLAGS) -o $@ $^
ping.o: ping.c
@yshl
yshl / bfi-0.c
Created Jul 27, 2013
Brainfuck Interpreter. bfi-0.c : ',' doesn't change memory cells at EOF. bfi-1.c : ',' returns -1 at EOF.
View bfi-0.c
c['~~'];d['~~'];*p=d;n;main(i,a,q)char**a,*q;{for(read(open(a[1],0),q=c,-1);*q;n<0?q--:q++)i=*q-44,i-49?i-47?n?0:i-2?p+=i-16?i?*p-=~i?i==1:i:read(0,p,1),i==18:-1:putchar(*p):(n+=!!n)|*p||n++:n--;}
@yshl
yshl / Makefile
Last active Dec 19, 2015
test of loop unrolling for matrix vector product in D
View Makefile
CC=gcc
CFLAGS=-Wall -O3 -march=native
DC=dmd
DFLAGS=-O -release -inline -m64
PROG=gemv1_c gemv2_c gemv3_c gemv4_c gemv1_d gemv2_d gemv3_d gemv4_d
all: $(PROG)
gemv1_c: gemv1_c.c
@yshl
yshl / fizzbuzz-1.scm
Last active Dec 19, 2015
FizzBuzz in Scheme
View fizzbuzz-1.scm
(define (fizzbuzz n c)
((lambda(d m g)
(g g 1
(lambda(l)
(m m l
(lambda(i c)
(d i 15
(lambda(b)
(if b
(c "FizzBuzz")
View crc-ccitt.bf
-> # dec{0} @1
++++[->++++<]> # {2}=16 @2
[-<+>[->>+<<]>>] # {1::31::2}=1 @34
-> # dec{34} @35
, # {35}=getchar()
+[- # while({35}!=EOF)
# p=35
[ # while({p#0})
# {p#1}={p#0}%2 {p#2}={p#0}/2
[ # while({p#0}){
View crc-16.bf
-> # dec{0} @1
++++[->++++<]> # {2}=16 @2
[-[->>+<<]>>] # @34
->> # dec{34} @36
, # {36}=getchar()
+[- # while({36}!=neg 1){
<++++++++ # {35}=8 @35
[ # while({35}){
-> # dec{35} @36
[ # while({36}){