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
class ConnsController < ApplicationController | |
before_filter :authenticate_user! | |
# GET /conns | |
# GET /conns.json | |
def index | |
@conns = current_user.conns | |
respond_to do |format| | |
format.html # index.html.erb | |
format.json { render json: @conns } |
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
(define empty-stack | |
(lambda () | |
(lambda (sym) | |
(cond ((eqv? sym 'empty-stack?) #t) | |
(else | |
(eopl:error 'empty-stack "stack is empty ~s" sym)))))) | |
(define push | |
(lambda (value stack) | |
(lambda (sym) |
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
(define bit-reversal | |
(lambda (str) | |
(let inner ((len (string-length str)) (instr str) (outstr "")) | |
(if (eq? 0 len) | |
outstr | |
(inner (- len 1) | |
(substring instr 1 (string-length instr)) | |
(string-append outstr | |
(cond ((string=? (substring instr 0 1) "0") "1") | |
((string=? (substring instr 0 1) "1") "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
(use gauche.test) | |
(add-load-path ".") | |
(load "env") | |
(test-start "list-find-last-position") | |
(test-section "list-find-last-position") | |
(test* "list-find-position" | |
1 | |
(list-find-position 'a '(c a b a c a d e))) |
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
(use gauche.test) | |
(add-load-path ".") | |
(load "env") | |
(test-start "has-association?") | |
(test-section "empty-env") | |
(test* "empty-env" | |
#f | |
(has-association? (empty-env) 'a)) |
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
(define empty-env | |
(lambda () | |
(lambda (sym search) | |
(if search | |
#f | |
(eopl:error 'apply-env "No binding for ~s" sym))))) | |
(define extend-env | |
(lambda (syms values env) | |
(lambda (sym search) |
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
(use gauche.test) | |
(add-load-path ".") | |
(load "env") | |
(test-start "env") | |
(test-section "environment-to-list") | |
(test* "example" | |
'(extended-env-record (d x) (6 7) | |
(extended-env-record (y) (8) |
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
(add-load-path "../../define-datatype") | |
(load "define-datatype") | |
(define-datatype environment environment? | |
(empty-env-record) | |
(extended-env-record | |
(syms (list-of symbol?)) | |
(vals (list-of scheme-value?)) | |
(env environment?))) |
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
(add-load-path "../../define-datatype") | |
(load "define-datatype") | |
(define-datatype stack stack? | |
(empty-stack-record) | |
(extended-stack-record | |
(val scheme-value?) | |
(stk stack?))) | |
(define scheme-value? |
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
(use gauche.test) | |
(add-load-path ".") | |
(load "stacks") | |
(test-start "stack") | |
(test-section "empty-stack") | |
(test* "empty-stack" | |
(test-error) | |
(stack-access 'pop (empty-stack))) |
OlderNewer