Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Test-a-function/Scala/test-a-function.scala
Normal file
18
Task/Test-a-function/Scala/test-a-function.scala
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import org.scalacheck._
|
||||
import Prop._
|
||||
import Gen._
|
||||
|
||||
object PalindromeCheck extends Properties("Palindrome") {
|
||||
property("A string concatenated with its reverse is a palindrome") =
|
||||
forAll { s: String => isPalindrome(s + s.reverse) }
|
||||
|
||||
property("A string concatenated with any character and its reverse is a palindrome") =
|
||||
forAll { (s: String, c: Char) => isPalindrome(s + c + s.reverse) }
|
||||
|
||||
property("If the first half of a string is equal to the reverse of its second half, it is a palindrome") =
|
||||
forAll { (s: String) => s.take(s.length / 2) != s.drop((s.length + 1) / 2).reverse || isPalindrome(s) }
|
||||
|
||||
property("If the first half of a string is different than the reverse of its second half, it isn't a palindrome") =
|
||||
forAll { (s: String) => s.take(s.length / 2) == s.drop((s.length + 1) / 2).reverse || !isPalindrome(s) }
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue