Gauche
å¢ãä½ã£ã¦ãé©ç¨ã§ããã¡ã½ããããªããã° method-missing ãå¼ã³åºããæ©è½ãä½ã£ã¦ã¿ãï¼ (define-generic method-missing) (define-class <method-missing-generic> (<generic>) ()) (define-method apply-methods ((gf <method-missing-generic>) methods args) (if (null? methods) (apply method-missing gf arg</method-missing-generic></generic></method-missing-generic>â¦
ãã£ãã: ãã³ã¾ ãããèªãã§polyglotãããã¼ã£ã¦æã£ãï¼ ä»åã®ã³ã³ã»ãã㯠åãã¦ãªã®ã§ããããHello, world! 好ããªè¨èªãçãè¾¼ã 140æåä»¥ä¸ ä»¥ä¸ï¼Schemeã¨è¨ãã¤ã¤Gauche決ãæã¡ã§ããï¼ ã½ã¼ã¹ã³ã¼ã ã§ãããã£ãã®ãããï¼ ;(#)={-"^<"v 'â¦
c-wrapperï¼c-wrapper ã¯æ´æ°ããã¦ããªããã© http://hg.koguro.net/c-wrapper ã§æ´æ°ããã¦ããï¼ãã¦ã³ãã¼ãâã¿ã°ãããã¦ã³ãã¼ãã§ããï¼ ./DIST gen ./configure CC=/usr/bin/gcc make DYLD_INSERT_LIBRARIES=/usr/lib/libffi.dylib make checkæ®éã«â¦
æè¿ã®Haskellã«ã¯ãã¿ã¼ã³ã¬ã¼ãã¨ãããã®ããããããï¼ {-# LANGUAGE PatternGuards #-} addLookup alist x y | Just m <- lookup x alist , Just n <- lookup y alist = m + n | otherwise = 0 main = print $ addLookup [(1, 2), (3, 4)] 1 3 -- => 6 â¦
shift/reset ã¨åçç°å¢ã®é¢ä¿ã«ã¤ãã¦ããããèãã¦ããæã«åºã¦ããå¯ç£ç©ï¼ (use util.match) (define (capture/de proc) (match (let/cc de (list (proc de))) ((r) r) (thunk (thunk)))) (define (with/de de thunk) (let/cc cont (de (.$ cont thunk)â¦
texi2html 1.70 ãå ¥ã£ã¦ããã®ã ãã©ãã¾ããããªãã£ã(1æéçµã£ã¦ãçµãããªãã£ã)ã®ã§ texi2html 1.82 ãã¤ã³ã¹ãã¼ã«ï¼ã½ã¼ã¹ã®docä¸ã§ make htmls ã§40ç§ç¨ã§ã§ããï¼make html ã¨ããã¨ã²ã¨ã¾ã¨ãã«ãªã£ãhtmlãåºæ¥ä¸ããï¼texi2htmlã®--splitãªãâ¦
Gaucheã®class.cããå¼ç¨ï¼ /* * compute-cpl */ ScmObj Scm_ComputeCPL(ScmClass *klass) { ScmObj seqh = SCM_NIL, seqt = SCM_NIL, ds, dp, result; /* a trick to ensure we have <object> <top> at the end of CPL. */ ds = Scm_Delete(SCM_OBJ(SCM_CLASS_OBJECT), k</top></object>â¦
(use gauche.collection) (use gauche.mop.singleton) (define-class <zero-collection-meta> (<singleton-meta>) ()) (define-class <zero-collection> (<collection>) () :metaclass <zero-collection-meta>) (define-method call-with-iterator ((class <zero-collection>) proc :key start) (proc (^ () #t) (^ () (errâ¦</zero-collection></zero-collection-meta></collection></zero-collection></singleton-meta></zero-collection-meta>
ååããèé¨ã® i ã®ä»£ããã«!ã使ããããã«ãªã£ãã®ã¨ré²æ°(r>1)ã使ããããã«ãªã£ãï¼ã㨠$try ã足ããªãæããã£ãã®ã§è¶³ãããï¼ææ©ï¼R5RSã®æ°å¤ãªãã©ã«ã£ã½ããã®ã§ã¯ãªããªã£ã¦ãã¦ããï¼ ååã®36é²æ°ã®èé¨ãæ±ãã¨ããåé¡ï¼ã³ã¡ã³ããé ããâ¦
R5RSã®æ°å¤ãªãã©ã«ã®ãµãã»ãããæ¡å¼µãããã®ã®ãã¼ã¶ãparser.pegã§æ¸ããï¼å ·ä½çã«ã¯å°æåãã使ããªãã®ã¨ 123### ãåã£ã¦å°æ°ã10é²ä»¥å¤ã§ãæ¸ããããã«ããæãï¼ãã¨36é²æ°ã¨ææ°ãã¼ã«ã«^ã追å ï¼ parser.pegã¯undocumentedã§ããåãããªãã®â¦
ããªããç¨ Haskell golf ã®æç§æ¸ãèªãã§ã俺ãããããã®æ¸ãããï¼ãã¨æã£ã¦æ¸ãã¦ã¿ãï¼(æã£ã¦ããæ¸ãã¾ã§ã«1å¹´ãããçµã£ã¦ããã©) ã¢ããã¥ã¢ã´ã«ãã¡ã¼ãªã®ã§è³ãã¬æãããããã ãã©ï¼ä»å¾ã®Schemeçã¨ããªããçã®çãä¸ãããé¡ã£ã¦ãã®æç« â¦
ã¨ã©ãã¹ããã¹ã®ç¯© (define (divisor? x y) (eqv? 0 (remainder x y))) (define-constant +primes+ (stream-cons 2 (stream-filter prime? (stream-iota -1 3 2)))) ;; (define (prime? n) ;; (not (stream-any (cut divisor? n <>) (stream-take-while (cuâ¦
$ gosh -V Gauche scheme shell, version 0.9 [utf-8,pthreads], i386-apple-darwin9.8.0 $ gosh gosh> (define-class <foo> () ()) <foo> gosh> (define-method foo ((self <foo>))) #<generic foo (1)> gosh> ((car (class-direct-methods <foo>))) something's wrong. $ è½ã¡ããï¼ç¬¬ä¸é¨å®ï¼ (</foo></generic></foo></foo></foo>â¦
gosh> (coerce-to <tree-map> '(("a" . 1) ("b" . 2))) WARNING: unknown keyword :size *** ERROR: real number required: "a" ããã¯=㨠ã¤ãã§ã«å¤ãªè¦ååºã¦ãï¼</tree-map>
Gaucheã®ãã㪠(lazy 3) ã許ãå¦çç³»ã ã¨ï¼å®ã¯delayã使ãæå³ã£ã¦ãªãã£ããããï¼
以åã®æ¥è¨ã§Gauche-readlineãæªããåãããã¦ããã®ãï¼åãããã«ãªã£ãï¼ ä»ã¾ã§ã®æå: $ DYLD_INSERT_LIBRARIES=/usr/local/lib/libreadline.dylib gosh-rl WARNING: Quote character setting is not supported by the library. gosh> gosh-rl ã§ããâ¦
gosh> (iota 5 3 0.1) (2.9999999999999996 3.0999999999999996 3.1999999999999997 3.3 3.4) gosh> (+ 3 0.1) 3.1ä½æ ï¼
ãããªæãã®sum-accãæ¸ãããã£ããã ãã©ï¼ãªããªã綺éºã«æ¸ããªãï¼ (sum-acc '(1 2 3 4)) ; => (1 3 6 10) ç´¯ç©åã®ãªã¹ãã£ã¦ããã®ããªï¼ ç´¯ç©ã£ã¦ãã¨ã§gauche.collectionã®map-accumã使ã£ã¦ã¿ãï¼ (use gauche.collection) (define (sum-acc lis) â¦
alist->tree-mapã¨tree-map->alistã¯çµã¿è¾¼ã¿ã ãã©ï¼alist->hash-tableã¨hash-table->alistã¯util.listã«å ¥ã£ã¦ããï¼ hash-tableã¨tree-mapã¯ä¼¼ã¦ãããã§(両æ¹ãªã®ã«)ä½ãã¨ä¸è²«æ§ããªãï¼tree-map-mapããªãã¨ã(以åæ¸ãã)ï¼ hash-tableã¯æ±ºãããã4â¦
gosh> (define-class <hoge> () ()) <hoge> gosh> (define-class <hoge-meta> (<class>) ()) <hoge-meta> gosh> (change-class <hoge> <hoge-meta>) *** ERROR: %transplant-instance: classes are incompatible between #<class #f> and #<class <hoge>> Stack Trace: _______________________________________ 0 (%transpâ¦</class></class></hoge-meta></hoge></hoge-meta></class></hoge-meta></hoge></hoge>
Gaucheã£ã¦ï¼ã¨ãããSRFI-1ã£ã¦map-reverseã¿ãããªã®ã£ã¦ãªãã®ãï¼ OCamlã«ã¯rev_mapããããããã®ããªã§åæã«å½ããåã®ããã«ããã¨æã£ã¦ããã©ãããªãã¨ã¯ãªãã£ãï¼ append-reverseã¯ããã®ã«â¦
0.8.14ã¨0.9ã§ç¢ºèªï¼ gosh> #`",'(#0=+ #0#)" "(+ +)" gosh> #`",(#0=+) ,(+)" "0 0" gosh> #`",(#0=+) ,(#0#)" *** ERROR: unmatched parenthesis in interpolating string: ",(#0=+) ,(#0#)" Stack Trace: _______________________________________ 0 (witâ¦
ä½æ ããããä»æ§ãªã®ãï¼ã©ãã«çåãæã£ããã¨ããã¨ï¼ã³ã¼ã«ããã¯ã«æ¸¡ãããäºã¤ã®é¢æ°ãï¼ãç¡å¼æ°ã§ä½åº¦ãå¼ã³åºããï¼éãå¤ãè¿ããã¨ãæå¾ ãããããã¨ï¼ã¤ã¾ãå¯ä½ç¨å¿ è³ãªã®ã ï¼å¤åï¼ ã©ãããªãé¢æ°çã«æ¸ãããããï¼ ã¨ããããã§ï¼å¯ä½ç¨â¦
ç¶ç¶ã¨ä¾å¤ããããã大åè±åºã«ä½¿ã£ã¦ï¼å®è¡æéãæ¯è¼ãã¦ã¿ãï¼3åè¨æ¸¬ãã¦ä¸å¤®å¤ãã¨ã£ãï¼ $ gosh -V Gauche scheme interpreter, version 0.8.14 [utf-8,pthreads]ã¾ãï¼æãåç´ãªä¾ï¼ (use srfi-42) (time (do-ec (: i 0 100000) (call/cc (lambda (â¦
$ gosh gosh> (define-module hoge (define foo 3) (export foo)) #<undef> gosh> (define-module fuga (import hoge) (export foo)) #<undef> gosh> (import fuga) #<undef> gosh> foo *** ERROR: unbound variable: foo Stack Trace: _______________________________________ g</undef></undef></undef>â¦
define-syntaxã§matchãå¼ã¶ã¨ã¨ã©ã¼ã«ãªãï¼ãã°ãããï¼ http://practical-scheme.net/wiliki/wiliki.cgi?Gauche%3aBugs%3alog9#H-w44n66 ãã ã¼ãï¼ ãã¯ãæããªãï¼ãã¯ããçæãããã¯ãã®"..."ã«ããã°ããããããï¼
gosh> (close-input-port (standard-input-port)) #<undef> gosh> *** IO-CLOSED-ERROR: I/O attempted on closed port: #<iport(closed) (stdin) 0x9db40> Stack Trace: _______________________________________ gosh> *** IO-CLOSED-ERROR: I/O attempted on closed port: #<iport(closed) (stdin) 0x9db40> Stack Traceâ¦</iport(closed)></iport(closed)></undef>
ãã¾ãåãã¦ããã¨æã£ãã®ã ãï¼composeã使ããã¨ãã¦ï¼è£å®ããã¾ãã§ããªããã¨ã«æ°ä»ãï¼R5RSã¨srfiã®ç¯å²ã¯è£å®ã§ããããã ï¼ããã£ã¦ã¿ãã¨ï¼Chickenã¨Gaucheã«ã¯å¯¾å¿ãã¦ãããããï¼ãããEmacsã®è¨å®ãã¡ã¤ã«ã«ã¯ã¡ããã¨è¨å®ãã³ãããã¦ããï¼â¦
readlineããªãã¦ä¸ä¾¿ãªã®ã§ï¼http://practical-scheme.net/gauche/packages-j.htmlã«ããreadlineã試ãã¦ã¿ãï¼ãï¼ä½¿ãæ¹ã解ããªãï¼ãµã³ãã«ããããã®ã試ãããåããã«ã¯åãããï¼æåãæªããï¼æ®éã«ã¤ã³ã¿ããªã¿ãã使ãæ¹æ³ã解ããªãã£ãã§ï¼â¦
gosh> #\page #\x0c gosh> #\tab #\tab gosh> #\lf #\newline gosh> #\cr #\return gosh> #\nul #\null gosh> #\sp #\space gosh> ä»æ¥ã®çºè¦ï¼ #\pageã ãæååã§è¡¨ç¤ºãããªãï¼ ãªãã¡ã¬ã³ã¹ã«ã¯æ¸ãã¦ããªããï¼#\spã¨#\nulã使ããï¼ R5RSã§å®ç¾©ããã¦â¦