egison 3.3.2 → 3.3.3
raw patch · 4 files changed
+21/−6 lines, 4 files
Files
- egison.cabal +1/−1
- hs-src/Language/Egison/Parser.hs +16/−4
- sample/binary-counter.egi +3/−0
- sample/sequence.egi +1/−1
egison.cabal view
@@ -1,5 +1,5 @@ Name: egison-Version: 3.3.2+Version: 3.3.3 Synopsis: Programming language with non-linear pattern-matching with backtracking Description: An interpreter for Egison, the programming langugage that realized non-linear pattern-matching with backtracking.
hs-src/Language/Egison/Parser.hs view
@@ -60,16 +60,28 @@ readExpr = liftEgisonM . runDesugarM . either throwError desugar . parseExpr parseTopExprs :: String -> Either EgisonError [EgisonTopExpr]-parseTopExprs = doParse $ whiteSpace >> endBy topExpr whiteSpace+parseTopExprs = doParse $ do+ ret <- whiteSpace >> endBy topExpr whiteSpace+ eof+ return ret parseTopExpr :: String -> Either EgisonError EgisonTopExpr-parseTopExpr = doParse $ whiteSpace >> topExpr+parseTopExpr = doParse $ do+ ret <- whiteSpace >> topExpr+ whiteSpace >> eof+ return ret parseExprs :: String -> Either EgisonError [EgisonExpr]-parseExprs = doParse $ whiteSpace >> endBy expr whiteSpace+parseExprs = doParse $ do+ ret <- whiteSpace >> endBy expr whiteSpace+ eof+ return ret parseExpr :: String -> Either EgisonError EgisonExpr-parseExpr = doParse $ whiteSpace >> expr+parseExpr = doParse $ do+ ret <- whiteSpace >> expr+ whiteSpace >> eof+ return ret -- |Load a libary file loadLibraryFile :: FilePath -> EgisonM [EgisonTopExpr]
+ sample/binary-counter.egi view
@@ -0,0 +1,3 @@+(define $bc (match-all {0 1} (set integer) [(loop $i [1 $n] <cons $x_i ...> _) (map (lambda [$i] x_i) (between 1 n))]))++(take 30 bc)
sample/sequence.egi view
@@ -4,7 +4,7 @@ ;;; ;;; -;; Extract all twin primes with non-linear pattern-matching against the infinite list of prime numbers+;; Extract all twin primes from the infinite list of prime numbers with pattern-matching! (define $twin-primes (match-all primes (list integer) [<join _ <cons $p <cons ,(+ p 2) _>>>