(dolist (var init-form result) S式 ... )
dolist は名前が示すように、リストに関係があります。最初に init-form を評価します。このとき、評価結果はリストでなければいけません。リスト以外の場合はエラーとなります。dolist は、このリストの要素を順番に変数 var に代入して S 式を評価します。リストの要素がなくなったら result を評価し、その値が dolist の返り値になります。次の例を見てください。
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
message = [67594220461269, 501237540280788, 718316769824518, 296304224247167, 48290626940198, 30829701196032, 521453693392074, <...> ] | |
p = 1007621497415251 | |
exponent = int((p-1)/2) | |
bresult = [1 if pow(m, exponent, p) == 1 else 0 for m in message] | |
bresultgroup = [''.join(str(y) for y in bresult[x:x+8]) for x in range(0, len(bresult), 8)] | |
''.join([chr(int(x, 2)) for x in bresultgroup]) |
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
Scheme 過去◇現在◇未来 前編 | |
bit/April 1996/Vol. 28, No.4 p4~9 | |
Guy L. Steele Jr. | |
訳 井田昌之 | |
---------------------------------------- | |
はじめに ――― 訳者より |
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
(defun zundoko() | |
(do((bit(random 2)(random 2)) | |
(memory 0 (shift memory bit))) | |
((= #b11110 memory)(princ :kiyoshi!)) | |
(if(zerop bit) | |
(princ :doko) | |
(princ :zun)))) | |
(defun shift(memory bit) | |
(ldb(byte 5 0)(dpb bit(byte 1 0)(ash memory 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
; たとえばこんなライブラリがあったとして… | |
(define-library (my lib) | |
(import (scheme base)) | |
(define foo 1) | |
(define bar 2) | |
(export foo) | |
(export (rename bar baz))) | |
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
;; -*- coding: utf-8; -*- | |
(define-module argparse) | |
(select-module argparse) | |
;; <help-formatter> は --help 用の文字列をフォーマットするやつだと思います。 | |
;; <argument-section> がその一部を管理する気がします。 | |
(define-class <help-formatter> () | |
;; prog はプログラムの名前を保持します。 | |
;; help 用の文字列に使われたり、version 情報にも使われます。 |
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-syntax %cut | |
(sc-macro-transformer | |
(lambda (form use-env) | |
(capture-syntactic-environment | |
(lambda (mac-env) | |
(let ((rargs (cadr form)) | |
(rbody (caddr form)) | |
(rest (cdddr form))) | |
(define (id=? x y) | |
(and (identifier? x) |
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 srfi-1) | |
;;; PEGタームは,入力文字列と解析位置を与えると,解析結果を返す関数. | |
;;; 解析に成功すると(次の位置 . 意味値)のペアを,失敗すると#fを返す. | |
;;; 解析結果ペア | |
(define (make-result pos value) (cons pos value)) | |
(define (position result) (car result)) | |
(define (value result) (cdr result)) |
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
##Q.1 | |
print "trats"[::-1] | |
##Q.2 | |
print 8 not in range(7,8) | |
##Q.3 | |
print 0.0 is 0 | |
##Q.4 |