Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/grp/   (Apache JAVA IDE Version 28©)  Datei vom 18.9.2025 mit Größe 59 kB image not shown  

Quellcodebibliothek properties.ML   Sprache: SML

 
(*  Title:      Pure/General/properties.ML
    Author:     Makarius

Property lists.
*)


signature PROPERTIES =
sig
  type entry = string * string
  type T = entry list
  val print_eq: entry -> string
  val entry_ord: entry ord
  val ord: T ord
  val defined: T -> string -> bool
  val get: T -> string -> string option
  val put: entry -> T -> T
  val remove: string -> T -> T
  val make_string: string -> string -> T
  val make_bool: string -> bool -> T
  val make_int: string -> int -> T
  val get_string: T -> string -> string
  val get_bool: T -> string -> bool
  val get_int: T -> string -> int
  val get_seconds: T -> string -> Time.time
end;

structure Properties: PROPERTIES =
struct

type entry = string * string;

type T = entry list;

fun print_eq (a, b) = a ^ "=" ^ b;

val entry_ord = prod_ord string_ord string_ord;
val ord = list_ord entry_ord;

fun defined (props: T) name = AList.defined (op =) props name;
fun get (props: T) name = AList.lookup (op =) props name;
fun put entry (props: T) = AList.update (op =) entry props;
fun remove name (props: T) = AList.delete (op =) name props;

fun make_string k s = if s = "" then [] else [(k, s)];
fun make_bool k b = if not b then [] else [(k, Value.print_bool b)];
fun make_int k i = if i = 0 then [] else [(k, Value.print_int i)];

val get_string = the_default "" oo get;

fun get_bool props name =
  (case get props name of
    NONE => false
  | SOME s => Value.parse_bool s);

fun get_int props name =
  (case get props name of
    NONE => 0
  | SOME s => Value.parse_int s);

fun get_seconds props name =
  (case get props name of
    NONE => Time.zeroTime
  | SOME s => Time.fromReal (the_default 0.0 (Real.fromString s)));

end;

100%


¤ Dauer der Verarbeitung: 0.1 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.