File: Rev2.curry

package info (click to toggle)
curry-tools 1.0.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,492 kB
  • ctags: 121
  • sloc: makefile: 470; sh: 421
file content (20 lines) | stat: -rw-r--r-- 477 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{-# OPTIONS_CYMAKE -F --pgmF=currypp --optF=defaultrules #-}
{-# OPTIONS_CYMAKE -Wnone #-}

import Test.EasyCheck

-- Reverse a list if it has exactly two elements:
rev2 :: [a] -> [a]
rev2 [x,y] = [y,x]
rev2'default xs = xs

main :: [[Int]]
main = map rev2 (map (\n->[1..n]) [0..4])

test1 = rev2 [] -=- []
test2 = rev2 [1] -=- [1]
test3 = rev2 [1,2] -=- [2,1]
test4 = rev2 [1,2,3] -=- [1,2,3]
test5 = rev2 [1,2,3,4] -=- [1,2,3,4]

test6 xs = length xs /= 2 ==> rev2 xs -=- xs