Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Delphi/Bille 0.71/   (Columbo Version 0.7©)  Datei vom 14.0.2013 mit Größe 2 kB image not shown  

Quelle  similarity.inc   Sprache: Delphi

 
//-------------------------------------------------------
//
//-------------------------------------------------------
function issimilar(L, R: String): boolean;
var
  vl, vr: String;
  res: boolean;
  //---------------------------------------------------------------
  function leadingzeroes(S: String): String;
  begin
    while (length(S) > 1) and (S[1] = '0'do
      S := midstr(S, 2, length(S) - 1);
    result := S
  end;
//---------------------------------------------------------------
  function trailingzeroes(S: String): String;
  var
    pp: integer;
  begin
    pp := pos(opt.r.decimalpoint, S);
    if pp > 0 then
      while (length(S) > pp) and (S[length(S)] = '0'do
        S := midstr(S, 1, length(S) - 1);
    if (length(S) >= pp) and (S[pp] = opt.r.decimalpoint) then
      S := midstr(S, 1, length(S) - 1);
    result := S
  end;
//---------------------------------------------------------------
  function removesign(S: String): String;
  begin
    if charinset(S[1], ['-''+']) then
      S := midstr(S, 2, length(S));
    result := S
  end;
//---------------------------------------------------------------
  function isPrefix(S1, S2: String): boolean;
  begin
    if (length(S1) < 3) or (length(S1) > length(S2)) then
      result := false
    else
      result := MidStr(S2, 1, length(S1)) = S1
  end;
//---------------------------------------------------------------
  function isnumber(S: String): boolean;
  var
    i, d, ll: integer;
    res: boolean;
  begin
    res := true;
    if length(S) = 0 then
      res := false;
    for i := 1 to length(S) do
      res := res and charinset(S[i], ['0' .. '9', opt.r.decimalpoint, '+''-',
        '$''€']);
    d := pos(opt.r.decimalpoint, S);
    if d > 0 then begin
      ll := length(S);
      d := pos(opt.r.decimalpoint, midstr(S, D + 1, ll));
      res := res and (d <= 0)
    end;
    result := res;
  end;
//---------------------------------------------------------------

begin
  //
  res := false;
  vl := L;
  vr := R;
  //remove separators
  vl := StringReplace(vl, FDB, '', [rfReplaceAll]);
  vr := StringReplace(vr, FDB, '', [rfReplaceAll]);
  //
  if isnumber(vl) and isnumber(vr) then begin
    //
    vl := removesign(vl);
    vr := removesign(vr);
    //leading 0's
    vl := leadingzeroes(vl);
    vr := leadingzeroes(vr);
    //trailing 0's
    vl := trailingzeroes(vl);
    vr := trailingzeroes(vr);
    //
    res := vl = vr;
  end;
  //
  result := res;
end;

98%


¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.