This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
// Example using GCC's inline assembler. | |
// Compute the sum of 1 to 10. | |
// GCCのインラインアセンブラを使った例。 | |
// 1から10までの総和を計算する。 | |
// use compiler option -masm=intel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
===Makefile=== | |
default: native | |
native: | |
ocamlbuild -use-ocamlfind -yaccflags --explain main.native | |
clean: | |
ocamlbuild -clean | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%token VAL1 EOF | |
%start <int option> prog | |
%% | |
prog: | |
| VAL1 { Some 1} | |
| EOF { None } | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List(sortBy) | |
myLength :: [a] -> Int | |
myLength [] = 0 | |
-- myLength (x:xs) = 1 + myLength xs | |
myLength (_:xs) = 1 + myLength xs | |
-- sumList :: [Double] -> Double | |
-- sumList [] = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn prime? [n] | |
(cond | |
(== n 1) false | |
(== n 2) true | |
(even? n) false | |
:else (->> (range 3 (inc (Math/sqrt n)) 2) | |
(every? #(pos? (rem n %)))))) | |
(def m-prime? (memoize prime?)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.xml :as xml]) | |
(defn twitter-followers [user-name] | |
(->> (str "https://api.twitter.com/1/users/show.xml?screen_name=" user-name) | |
xml/parse | |
:content | |
(filter (comp #{:followers_count} :tag)) | |
first | |
:content | |
first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Clojure logger example | |
(defn print-logger [writer] | |
#(binding [*out* writer] | |
(println %))) | |
(def *out*-logger (print-logger *out*)) | |
(def writer (java.io.StringWriter.)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* common-lisp: format: | |
~a aesthetic | |
~s readで読める形式 | |
~:a nil → () で出力 | |
~% 改行 | |
~& 先頭でないときに改行 | |
~5% 5個改行 | |
~~ ~を出力 | |
~5~ 5個出力 | |
~c 文字 |