Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  word.gi   Sprache: Shell

 

#############################################################################
##
##  fp/word.gi
##  Copyright (C) 2020-2022                                 Maria Tsalakou
##
##  Licensing information can be found in the README file of this package.
##
#############################################################################
##

InstallMethod(WordToString, "for a string and a homogeneous list",
[IsString, IsHomogeneousList],
function(alphabet, word)
  if IsEmpty(word) then
    return "";
  elif not ForAll(word, IsPosInt) then
    ErrorNoReturn("expected list of positive integers as 2nd argument");
  elif Maximum(word) > Length(alphabet) then
    ErrorNoReturn("the 1st argument (a string) is too short, ",
                  "expected at least ", Maximum(word),
                  " but found ", Length(alphabet));
  fi;
  return List(word, i -> alphabet[i]);
end);

InstallMethod(RandomWord, "for two integers",
[IsInt, IsInt],
function(length, number_letters)
  if length < 0 then
    ErrorNoReturn("expected non-negative integer as 1st argument");
  elif number_letters < 0 then
    ErrorNoReturn("expected non-negative integer as 2nd argument");
  elif number_letters = 0 and length > 0 then
    ErrorNoReturn("the 1st argument (an integer) cannot be ",
                  "non-zero if the 2nd argument is 0");
  fi;
  return List([1 .. length], x -> Random([1 .. number_letters]));
end);

InstallMethod(StandardiseWord, "for a homogeneous list",
[IsHomogeneousList],
function(word)
  local distinct_chars, lookup, i;

  if IsEmpty(word) then
    return word;
  elif not ForAll(word, IsPosInt) then
    ErrorNoReturn("expected a list of positive integers as 2nd argument");
  fi;

  distinct_chars := 1;
  lookup         := [];

  for i in [1 .. Length(word)] do
    if IsBound(lookup[word[i]]) then
      word[i] := lookup[word[i]];
    else
      lookup[word[i]]   := distinct_chars;
      word[i]           := distinct_chars;
      distinct_chars    := distinct_chars + 1;
    fi;
  od;
  return word;
end);

InstallMethod(StringToWord, "for a string", [IsString],
w -> StandardiseWord(List(w, IntChar)));

Messung
CHZG
8410010094

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

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 und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1104857
#Domains=438777