This file contains hidden or 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
| (define (make-generic) | |
| (letrec ((self (lambda args | |
| (let ((m (find-method self args))) | |
| (if m | |
| (apply m args) | |
| (error "method not found")))))) | |
| (add-generic self) | |
| self)) | |
This file contains hidden or 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 (gauche base)) | |
| (import (prefix (gauche partcont) gosh-)) | |
| ; = util = | |
| (define-syntax push! | |
| (syntax-rules () | |
| ((push! obj list) | |
| (set! list (cons obj list))))) |
This file contains hidden or 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 (picrin base)) | |
| (define-class <bool> | |
| boolean?) | |
| (define-class <value> | |
| (lambda (x) #t)) | |
This file contains hidden or 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> | |
| #include <stdint.h> | |
| typedef uint32_t uint; | |
| uint | |
| read_ins() | |
| { | |
| uint u = 0; |
This file contains hidden or 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
| int __and(int a, b) { | |
| int i, x; | |
| x = 0; | |
| for (i = 31; i >= 0; --i) { | |
| x = x << 1; | |
| if (__bitget(a, i) + __bitget(b, i) >= 2) { | |
| x += 1; | |
| } | |
| } |
This file contains hidden or 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
| entity DataCache is | |
| port ( | |
| clk : in std_logic; | |
| addr : in std_logic_vector(31 downto 0); | |
| -- read | |
| rx_en : in std_logic; | |
| rx_data : out std_logic_vector(31 downto 0); | |
| rx_hit : out std_logic; | |
| -- write | |
| tx_en : in std_logic; |
This file contains hidden or 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
| let rec create_2dmatrix a b c d = | |
| let matrix = Array.create 2 (Array.create 0 0.0) in | |
| matrix.(0)<-Array.create 2 0.0; | |
| matrix.(1)<-Array.create 2 0.0; | |
| let mx_0 = matrix.(0) in | |
| mx_0.(0)<- a; | |
| mx_0.(1)<- b; | |
| let mx_1 = matrix.(1) in | |
| mx_1.(0)<- c; | |
| mx_1.(1)<- d; |
This file contains hidden or 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> | |
| #include <stdint.h> | |
| uint32_t | |
| E(uint32_t x, int i, int j) /* i and j are inclusive */ | |
| { | |
| return (((1 << (i + 1)) - 1) & x) >> j; | |
| } | |
| uint32_t |
This file contains hidden or 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
| :- use_module(library(socket)). | |
| write_atom(Stream,Atom) :- | |
| atom_codes(Atom,Codes), | |
| write_codes(Stream,Codes). | |
| write_codes(_,[]) :- !. | |
| write_codes(Stream,[Code|Tail]) :- | |
| put_code(Stream,Code), | |
| write_codes(Stream,Tail). |
This file contains hidden or 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
| #!/usr/bin/env python2.7 | |
| # | |
| # Usage: ./asm.py foo.s > foo.out | |
| import sys, re | |
| filename = sys.argv[1] | |
| def parse(line): | |
| line = line.strip() |