File: FloatString.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 (18 lines) | stat: -rw-r--r-- 460 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{-# OPTIONS_CYMAKE -F --pgmF=currypp --optF=defaultrules #-}

import Test.EasyCheck

-- Example: predicate to check for float strings

import Char(isDigit)

-- Is the argument a non-negative float string (without exponent)?
isNNFloat :: String -> Bool
isNNFloat (f1 ++ "." ++ f2) | (all isDigit f1 && all isDigit f2) = True
isNNFloat'default _ = False

main = map isNNFloat ["3.14","314"]

test1 = isNNFloat "3.14" -=- True
test2 = isNNFloat "314"  -=- False