<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vantage Point of Queens &#187; Gauche</title>
	<atom:link href="http://blog.nydd.org/topic/study-note/gauche/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nydd.org</link>
	<description>Art, Hack and Rock'n Roll</description>
	<lastBuildDate>Wed, 16 Jun 2010 13:59:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>プログラミング Gauche &#8211; Chapter 4 and 5</title>
		<link>http://blog.nydd.org/2010/01/programming-gauche-4_5/</link>
		<comments>http://blog.nydd.org/2010/01/programming-gauche-4_5/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 01:15:42 +0000</pubDate>
		<dc:creator>beatak</dc:creator>
				<category><![CDATA[Gauche]]></category>
		<category><![CDATA[Study Note]]></category>

		<guid isPermaLink="false">http://blog.nydd.org/?p=313</guid>
		<description><![CDATA[				さてつまみ食いで読み進めてきた プログラミング Gauche ですが、Emacs にもなれてきたし、最初から順に読み直してみようかと思いました。
				Chapter 4
				以下の Elisp を .emacs.el に追加しました。gosh は確かに Emacs 内から起動した方が便利な感じがしますね。というか gosh を rlwrap する shellscript を書くべきなんですね。
				
(setq scheme-program-name "gosh -i")
(autoload 'scheme-mode "cmuscheme" "Major mode for Scheme." t)
(autoload 'run-scheme "cmuscheme" "run an iferior Scheme process." t)

(defun scheme-other-window ()
  "Run scheme on other window"
  (interactive)
  (switch-to-buffer-other-window
    (get-buffer-create "*scheme*"))
  [...]]]></description>
			<content:encoded><![CDATA[				<p><iframe src="http://rcm-jp.amazon.co.jp/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=grfdesign-22&#038;o=9&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=1X69VDGQCMF7Z30FM082&#038;asins=4873113482" style="width:120px;height:240px;float:right;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>さてつまみ食いで読み進めてきた プログラミング Gauche ですが、Emacs にもなれてきたし、最初から順に読み直してみようかと思いました。<br style="clear:both;" /></p>
				<h4>Chapter 4</h4>
				<p>以下の Elisp を .emacs.el に追加しました。gosh は確かに Emacs 内から起動した方が便利な感じがしますね。というか gosh を rlwrap する shellscript を書くべきなんですね。</p>
				<pre class="prettyprint">
(setq scheme-program-name "gosh -i")
(autoload 'scheme-mode "cmuscheme" "Major mode for Scheme." t)
(autoload 'run-scheme "cmuscheme" "run an iferior Scheme process." t)

(defun scheme-other-window ()
  "Run scheme on other window"
  (interactive)
  (switch-to-buffer-other-window
    (get-buffer-create "*scheme*"))
  (run-scheme scheme-program-name))

(define-key global-map "\C-cs" 'scheme-other-window)
</pre>
				<p>Scheme mode 用のキーストロークで僕がメモを取ったのは以下です。普通のカーソル移動の C-a は行ベースで移動しますが、M-C-a では S式ベースで移動します。面白いですね。</p>
				<table>
				<tr>
				<td><code class="prettyprint">C-x C-e</code></td>
				<td><code class="prettyprint">scheme-send-last-sexp</code></td>
				<td>Send the previous sexp to the inferior Scheme process.</td>
				</tr>
				<tr>
				<td><code class="prettyprint">C-c C-e</code></td>
				<td><code class="prettyprint">scheme-send-definition</code></td>
				<td>Put the end of the buffer at the bottom of the window.</td>
				</tr>
				<tr>
				<td><code class="prettyprint">C-c C-r</code></td>
				<td><code class="prettyprint">scheme-send-region</code></td>
				<td>Display start of this batch of interpreter output at top of window. Sets mark to the value of point when this command is run.</td>
				</tr>
				<tr>
				<td><code class="prettyprint">C-c C-l</code></td>
				<td><code class="prettyprint">scheme-load-file</code></td>
				<td>Load a Scheme file FILE-NAME into the inferior Scheme process.</td>
				</tr>
				<tr>
				<td><code class="prettyprint">M-C-f</code></td>
				<td><code class="prettyprint">forward-sexp</code></td>
				<td>&nbsp;</td>
				</tr>
				<tr>
				<td><code class="prettyprint">M-C-b</code></td>
				<td><code class="prettyprint">backward-sexp</code></td>
				<td>&nbsp;</td>
				</tr>
				<tr>
				<td><code class="prettyprint">M-C-a</code></td>
				<td><code class="prettyprint">beginning-of-defun</code></td>
				<td>&nbsp;</td>
				</tr>
				<tr>
				<td><code class="prettyprint">M-C-e</code></td>
				<td><code class="prettyprint">end-of-defun</code></td>
				<td>&nbsp;</td>
				</tr>
				<tr>
				<td><code class="prettyprint">M-C-d</code></td>
				<td><code class="prettyprint">down-list</code></td>
				<td>&nbsp;</td>
				</tr>
				<tr>
				<td><code class="prettyprint">M-C-u</code></td>
				<td><code class="prettyprint">backward-up-list</code></td>
				<td>&nbsp;</td>
				</tr>
				<tr>
				<td><code class="prettyprint">M-C-t</code></td>
				<td><code class="prettyprint">transpose-sexps</code></td>
				<td>&nbsp;</td>
				</tr>
				</table>
				<h4>Chapter 5</h4>
				<p>シェルから直接立ち上がる Scheme を作る場合は以下のようにして、shebang をつけるのと、文字エンコードのヒントを入れておくといいらしい。</p>
				<pre class="prettyprint">
#!/usr/local/bin/gosh
;; -*- codeing: utf-8 -*-
(define (main args)
  (print (string-join (cdr args) "\u3042"))
  0)
</pre>
				<p>定番の fizzbuzz は以下のようになりました。</p>
				<pre class="prettyprint">
(use srfi-1)
(define (fizz-buzz max)
  (define (check-num x)
  (cond [(zero? (modulo x 15)) 'FizzBuzz]
        [(zero? (modulo x 5)) 'Buzz]
        [(zero? (modulo x 3)) 'Fizz]
        [else x]))
  (map check-num (iota max 1)))
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.nydd.org/2010/01/programming-gauche-4_5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
