Docs GODI Archive
Projects Blog Link DB

Search GODI:


More options
File lib/felix/lib/flx_categories.flx GODI Package apps-felix
 
   flx_categories.flx  
#line 224 "lpsrc/flx_lib.ipk"
  macro proc gen_eq(t){
    fun eq: t * t -> bool = "$1==$2" ;
    fun ne: t * t -> bool = "$1!=$2" ;
  }

  macro proc gen_cmp(t){
    gen_eq t;
    fun lt: t * t -> bool = "$1<$2" ;
    fun gt: t * t -> bool = "$1>$2" ;
    fun le: t * t -> bool = "$1<=$2" ;
    fun ge: t * t -> bool = "$1>=$2" ;
  }

  // additive group
  macro proc gen_add (t){
    fun pos: t -> t = "+$1" ;
    fun neg: t -> t = "-$1" ;
    fun add: t * t -> t = "$1+$2" ;
    fun sub: t * t -> t = "$1-$2" ;
    proc pluseq: lvalue[t] * t = "$1+=$2;";
    proc minuseq: lvalue[t] * t = "$1-=$2;";
  }

  // ring
  macro proc gen_arith(t){
    gen_add t;
    fun mul: t * t -> t = "$1*$2" ;
    fun div: t * t -> t = "$1/$2" ;
    proc muleq: lvalue[t] * t = "$1*=$2;";
    proc diveq: lvalue[t] * t = "$1/=$2;";
  }

  // division ring
  macro proc gen_dring(t){
    gen_arith t;
    fun mod : t * t -> t = "$1%$2" ;
    proc modeq: lvalue[t] * t = "$1%=$2;";
  }

  macro proc gen_forward (t){
    fun succ: t -> t = "$1:add + 1" is add;
    proc pre_incr:  lvalue[t] = "++$1;";
    proc post_incr: lvalue[t] = "$1++;";
  }

  macro proc gen_bidirectional(t){
    gen_forward t;
    fun pred: t -> t = "$1:add - 1" is add;
    proc pre_decr:  lvalue[t] = "--$1;";
    proc post_decr: lvalue[t] = "$1--;";
  }

  macro proc gen_random(t){
    gen_bidirectional t;
    fun add: t * int -> t = "$1+$2";
    fun sub: t * int -> t = "$1-$2";
    proc pluseq: lvalue[t] * int = "$1+=$2;";
    proc minuseq: lvalue[t] * int = "$1-=$2;";
  }

  // division ring
  macro proc gen_integral(t){
    gen_cmp t;
    gen_dring t;
    gen_bidirectional t;
  }


This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml