1 |
|
2 |
|
3 |
|
4 |
|
5 | strcmp = (str1, str2) ->
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | if str1 == str2 then 0 else if str1 > str2 then 1 else -1
|
16 |
|
17 |
|
18 | doubleToReasonableString = (d) ->
|
19 |
|
20 |
|
21 |
|
22 | if codeGen
|
23 | return d + ""
|
24 |
|
25 |
|
26 |
|
27 | stringRepresentation = "" + parseFloat(d.toPrecision(6))
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | if stringRepresentation.indexOf(".") == -1
|
33 | stringRepresentation += ".0"
|
34 |
|
35 | return stringRepresentation
|
36 |
|
37 |
|
38 | clear_term = ->
|
39 |
|
40 |
|
41 | isspace = (s) ->
|
42 | if !s? then return false
|
43 | return s == ' ' or s == '\t' or s == '\n' or s == '\v' or s == '\f' or s == '\r'
|
44 |
|
45 | isdigit = (str) ->
|
46 | if !str? then return false
|
47 | return /^\d+$/.test(str)
|
48 |
|
49 | isalpha = (str) ->
|
50 | if !str? then return false
|
51 |
|
52 | return (str.search(/[^A-Za-z]/) == -1)
|
53 |
|
54 | isalphaOrUnderscore = (str) ->
|
55 | if !str? then return false
|
56 |
|
57 | return (str.search(/[^A-Za-z_]/) == -1)
|
58 |
|
59 | isunderscore = (str) ->
|
60 | if !str? then return false
|
61 | return (str.search(/_/) == -1)
|
62 |
|
63 | isalnumorunderscore = (str) ->
|
64 | if !str? then return false
|
65 | return (isalphaOrUnderscore(str) or isdigit(str))
|