- 無名関数と
return
で小話を一席
- Twitter: dico_leque
- 趣味 Schemer
- お仕事で Scala とか OCaml とか F# とか Java とか
(use parser.peg) | |
(define ($look-ahead parse) | |
(lambda (s0) | |
(receive (r v s) (parse s0) | |
(values r v s0)))) | |
;; #/A*B/ で A, B それぞれの開始文字列に共通部分がない場合 | |
(define (f a b-start b) | |
($do (h ($many-till a ($look-ahead b-start))) |
(use parser.peg) | |
(define ($look-ahead parse) | |
(lambda (s0) | |
(receive (r v s) (parse s0) | |
(values r v s0)))) |
trait Monad[M[_]] { | |
def unit[A](x : A) : M[A] | |
def bind[A, B](m : M[A], f : A => M[B]) : M[B] | |
} | |
implicit object OptionMonad extends Monad[Option] { | |
def unit[A](x : A) = Some(x) | |
def bind[A, B](m : Option[A], f : A => Option[B]) = m.flatMap(f) |
// Direct-Style Monads in Scala | |
object Fpm2012 { | |
trait Monad[M[_]] { | |
def unit[A](x : A) : M[A] | |
def bind[A, B](m : M[A], f : A => M[B]) : M[B] | |
} | |
implicit object OptionMonad extends Monad[Option] { | |
def unit[A](x : A) = Some(x) |
diff --git a/src/gauche.h b/src/gauche.h | |
index 9ae7aa2..106b115 100644 | |
--- a/src/gauche.h | |
+++ b/src/gauche.h | |
@@ -1456,6 +1456,7 @@ SCM_EXTERN ScmObj Scm_MakeSubr(ScmSubrProc *func, | |
int required, int optional, | |
ScmObj info); | |
SCM_EXTERN ScmObj Scm_NullProc(void); | |
+SCM_EXTERN ScmObj Scm_BoundaryProc(void); | |
// origial: https://gist.github.com/koropicot/6265729 | |
// NYSL Version 0.9982 | |
trait Functor[F[_]] { | |
def fmap[A, B](fa: F[A])(f: A => B): F[B] | |
} | |
class Const[A, +B](val value: A) | |
class Identity[A](val value: A) |
;;; pattern guards a la Haskell | |
;;; 元ネタ: http://d.hatena.ne.jp/gengar/20130909/1378719785 | |
(use util.match) | |
(define-syntax do-match* | |
(syntax-rules () | |
((_ binds body ...) | |
(%do-match* #f binds body ...)))) |
diff --git a/lib/gauche/regexp.scm b/lib/gauche/regexp.scm | |
index 76cdb44..3ca5c1c 100644 | |
--- a/lib/gauche/regexp.scm | |
+++ b/lib/gauche/regexp.scm | |
@@ -190,7 +190,7 @@ | |
[(assert nassert) (apply unparse-assert-like test)] | |
[else (err "invalid AST in the test part of cpat" test)])) | |
(seq yes) | |
- (when no (disp "|") (seq no)) | |
+ (unless (null? no) (disp "|") (seq no)) |
diff --git a/src/regexp.c b/src/regexp.c | |
index 7a621fd..58c621e 100644 | |
--- a/src/regexp.c | |
+++ b/src/regexp.c | |
@@ -2476,9 +2476,11 @@ static void rex_rec(const unsigned char *code, | |
case RE_BEGIN: { | |
int grpno = *code++; | |
const char *opos = ctx->matches[grpno]->startp; | |
+ const char *oend = ctx->matches[grpno]->endp; | |
ctx->matches[grpno]->startp = input; |