Skip to content

Commit

Permalink
fold done.
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed May 2, 2017
1 parent 9d1a6c0 commit d3938f6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ CI|status
:---|:---:
Travis CI|[![Build Status](https://travis-ci.org/lice-lang/lice.svg?branch=master)](https://travis-ci.org/lice-lang/lice)
AppVeyor|[![Build status](https://ci.appveyor.com/api/projects/status/7d6lyinb0xr6hagn?svg=true)](https://ci.appveyor.com/project/ice1000/lice/branch/master)
CodeShip|[![CodeShip](https://codeship.com/projects/ce3500b0-0a1d-0135-8b3c-6ed4d7e33e57/status?branch=master)](https://app.codeship.com/projects/214703)
CircleCI|[![CircleCI](https://circleci.com/gh/lice-lang/lice/tree/master.svg?style=svg)](https://circleci.com/gh/lice-lang/lice/tree/master)

[![JitPack](https://jitpack.io/v/lice-lang/lice.svg)](https://jitpack.io/#lice-lang/lice)<br/>
Expand Down Expand Up @@ -42,7 +41,7 @@ allprojects {
}
dependencies {
compile 'com.github.lice-lang:lice:v3.1'
compile 'com.github.lice-lang:lice:v3.1.1'
}
```

Expand All @@ -51,15 +50,15 @@ But if you use Scala, you can add it to your sbt dependency, by adding the stuff
```sbtshell
resolvers += "jitpack" at "https://jitpack.io"
libraryDependencies += "com.github.lice-lang" % "lice" % "v3.1"
libraryDependencies += "com.github.lice-lang" % "lice" % "v3.1.1"
```

And if you're a Clojure developer, why not try build it with leiningen?

```leiningen
:repositories [["jitpack" "https://jitpack.io"]]
:dependencies [[com.github.lice-lang/lice "v3.1"]]
:dependencies [[com.github.lice-lang/lice "v3.1.1"]]
```

## Contribute
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'org.lice'
version '3.1'
version '3.1.1'

buildscript {
ext.kotlin_version = '1.1.2-2'
Expand Down
11 changes: 11 additions & 0 deletions src/test/kotlin/org/lice/FeatureTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,20 @@ side-effect

/**
* lambda as parameter
*
* sample: defining a fold
*/
@Test(timeout = 1000)
fun test33() {
"((expr op (op 1 2)) (lambda a b (+ a b)))" shouldBe 3
"((expr op (op 3 4)) (lambda a b (+ (* a a) (* b b))))" shouldBe 25
//language=TEXT
"""
(defexpr fold ls init op
(for-each index-var ls
(-> init (op init index-var))))
(fold (.. 1 4) 0 +)
""" shouldBe 10
}
}
16 changes: 16 additions & 0 deletions src/test/kotlin/org/lice/StdTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.junit.Test
import org.lice.compiler.parse.createRootNode
import org.lice.compiler.util.forceRun
import org.lice.compiler.util.println
import org.lice.lang.Echoer
import java.io.File

/**
Expand Down Expand Up @@ -81,6 +82,21 @@ class StdTest {
else println(ls.last())
}

@Test
fun testKotlinSupportLambdaRec() {
fun lambda(it: Int): Int = if (it <= 2) 1 else lambda(it - 1) + lambda(it - 2)
Echoer.printer = ::println
(1..10)
.map(::lambda)
.forEach(Echoer::echoln)

var lambda2: (Int) -> Int = { it }
lambda2 = { if (it <= 2) 1 else lambda(it - 1) + lambda(it - 2) }
(1..10)
.map(lambda2)
.forEach(Echoer::echoln)
}

companion object {
@JvmStatic
fun main(args: Array<String>) {
Expand Down

0 comments on commit d3938f6

Please sign in to comment.