File: string_extra.ml

package info (click to toggle)
hol88 2.02.19940316-8
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 63,120 kB
  • ctags: 19,367
  • sloc: ml: 199,939; ansic: 9,300; sh: 7,118; makefile: 6,074; lisp: 2,747; yacc: 894; sed: 201; cpp: 87; awk: 5
file content (30 lines) | stat: -rw-r--r-- 1,789 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
%****************************************************************************%
% FILE          : string_extra.ml                                            %
% DESCRIPTION   : Additional functions for ML strings.                       %
%                                                                            %
% READS FILES   : <none>                                                     %
% WRITES FILES  : <none>                                                     %
%                                                                            %
% AUTHOR        : R.J.Boulton                                                %
% DATE          : 4th March 1991                                             %
%                                                                            %
% LAST MODIFIED : R.J.Boulton                                                %
% DATE          : 13th January 1992                                          %
%****************************************************************************%

%----------------------------------------------------------------------------%
% string_less : string -> string -> bool                                     %
%                                                                            %
% Lexicographical less-than on strings.                                      %
%----------------------------------------------------------------------------%

let string_less s1 s2 =
   letrec string_less' l1 l2 =
      if (null l2) then false
      if (null l1) then true
      else let a1 = ascii_code (hd l1)
           and a2 = ascii_code (hd l2)
           in  if (a1 < a2) then true
               if (a1 = a2) then string_less' (tl l1) (tl l2)
               else false
   in string_less' (explode s1) (explode s2);;