Hi Gabriel, and all...

> Well, personally, I did find the script plain obfuscation to tell the
> truth :-) So I was not surprising, nor annoyed.  But, that isn't a
> universally hold; which is why I'm raising the question here, to see
> what people think.

Indeed type in axiom/spad are rough when I compare it to caml.

In axiom it seems I must read line after line the type I want to get.
With caml the very last line of code imposes the type to the variable.

> Indeed, it is in the context of Spad script where the type inference
> rules are not all written out.   I would be happy to sweep it under
> the rug if people feel comfortable with that.

I feel that type error in caml often shows real misunderstanding,
and axiom/spad type error are due to unfair choice from the interpreter.

And I'm not clear with subtype as NNI, PI and INT. 
The a-b operation over NNI for matrix index is boring.

------------------------------------------------------------------------

You join this question to anonymous function :

Sometime ago I try to use axiom for this question. 

Find the operations over [2,3,4,6] in order to find 121 or 16 or ...

I make 4 tries, it works but I find no fair solutions. 
I will be happy if I can 
  code map ... map ...
  use untype a lot of function
  only call +-> anonymous functions without signature
  use list of anonymous functions

Axiom find a reponse with axiom, but I get it with a fuzzy logic.
  
By example take the result line 75. : res2 := set concat concat res
extract the numbers             res3 := select (x +-> x case Integer, res2)
I try to find what results are common. 

so I test # select (n +-> n=5, res3) -- it's right
-- this result is the number of 5 in the list.
but I try [# select (n +-> n=k , res3) for k in 1..10] and I get an error. 

Have a nice day !

F.

L := [2,3,4,6]

Lnb1 := concat 
  [concat 
    [concat [[[L.i1, L.i2, L.i3, L.i4] for i1 in 1..4] for i2 in 1..4]
       for i3 in 1..4] for i4 in 1..4]

Lnb := select (ll +-> test (# set ll = 4), Lnb1)

Lop1 := [(x,y) +-> x+y, (x,y) +-> if x>y then x-y else "failed",
  (x,y) +-> x*y, (x,y) +-> if y~=0 and x rem y = 0 then x/y else "failed"]

Lop := map (fct +-> 
  ((x,y) +-> if (x case String) or (y case String) 
               then "failed" else fct(x,y)), 
    Lop1)
-- pb 1 - 2::Union (String, Integer)  -> String
--        mais 2::Union (Integer,String)   -> Integer
-- pb 2 - Lop := map (fct +-> ((x,y) +-> fct(x,y)), Lop1) ne marche pas


TUIS := Union (Integer, String)
fct1 : (Integer, Integer) -> TUIS
fct2 : (Integer, Integer) -> TUIS
fct3 : (Integer, Integer) -> TUIS
fct4 : (Integer, Integer) -> TUIS
fct1 (x, y) == x+y
fct2 (x, y) == if x>y then x-y else "failed"
fct3 (x, y) == x*y
fct4 (x, y) == if y~=0 and x rem y = 0 then x/y else "failed"

Lop1a := [fct1, fct2, fct3, fct4]

Lopa := [((x,y) +-> if (x case String) or (y case String) 
               then "failed" else fct(x,y)) for fct in Lop1a]

-- ne marche pas

fct1a : (TUIS, TUIS) -> TUIS
fct2a : (TUIS, TUIS) -> TUIS
fct3a : (TUIS, TUIS) -> TUIS
fct4a : (TUIS, TUIS) -> TUIS

fct1a (x,y) == 
  if (x case String) or (y case String) then "failed" else fct1 (x,y)
fct2a (x,y) == 
  if (x case String) or (y case String) then "failed" else fct2 (x,y)
fct3a (x,y) == 
  if (x case String) or (y case String) then "failed" else fct3 (x,y)
fct4a (x,y) == 
  if (x case String) or (y case String) then "failed" else fct4 (x,y)

Lopaa := [fct1a, fct2a, fct3a, fct4a]
LLop := concat 
 [concat [[[Lopaa.i1, Lopaa.i2, Lopaa.i3] for i1 in 1..4] for i2 in 1..4] 
    for i3 in 1..4] 

calculsa (Ln, Lop) ==
  [(Lop.3)((Lop.2)((Lop.1)(Ln.1,Ln.2),Ln.3),Ln.4),       -- ((x % y) % z) % t
    (Lop.2)((Lop.1)(Ln.1,Ln.2),(Lop.3)(Ln.3,Ln.4)),      -- (x % y) % (z % t)
     (Lop.3)((Lop.1)(Ln.1,(Lop.2)(Ln.2,Ln.3)),Ln.4),     -- (x % (y % z)) % t
      (Lop.1)(Ln.1,(Lop.3)((Lop.2)(Ln.2,Ln.3),Ln.4)),    -- x % ((y % z) % t)
       (Lop.1)(Ln.1,(Lop.2)(Ln.2,(Lop.3)(Ln.3,Ln.4)))]   -- x % (y % (z % t))
  
calculs ([2,3,4,6]::List TUIS, Lopaa)

calculs := (Ln, Lop) +-> 
  [(Lop.3)((Lop.2)((Lop.1)(Ln.1,Ln.2),Ln.3),Ln.4),      -- ((x % y) % z) % t
    (Lop.2)((Lop.1)(Ln.1,Ln.2),(Lop.3)(Ln.3,Ln.4)),      -- (x % y) % (z % t)
     (Lop.3)((Lop.1)(Ln.1,(Lop.2)(Ln.2,Ln.3)),Ln.4),     -- (x % (y % z)) % t
      (Lop.1)(Ln.1,(Lop.3)((Lop.2)(Ln.2,Ln.3),Ln.4)),    -- x % ((y % z) % t)
       (Lop.1)(Ln.1,(Lop.2)(Ln.2,(Lop.3)(Ln.3,Ln.4)))]   -- x % (y % (z % t))
  
res := [[calculs (nbs, lop) for nbs in Lnb] for lop in LLop]
set concat concat res 

----------------------------------------------------

L := [2,3,4,6]

Lnb1 := concat 
  [concat 
    [concat [[[L.i1, L.i2, L.i3, L.i4] for i1 in 1..4] for i2 in 1..4]
       for i3 in 1..4] for i4 in 1..4]

Lnb := select (ll +-> test (# set ll = 4), Lnb1)

TUIS := Union (Integer, String)
fcta : (Integer, Integer, String, String) -> List Any
fctb : (Integer, Integer, String, String) -> List Any
fctc : (Integer, Integer, String, String) -> List Any
fctd : (Integer, Integer, String, String) -> List Any
fcta (x, y, sx, sy) == [x+y::TUIS, concat [sx, "+", sy]]
fctc (x, y, sx, sy) == [x*y::TUIS, concat [sx, "*", sy]]
fctb (x, y, sx, sy) == 
  if x>y 
  then [x-y::TUIS, concat [sx, "+", sy]]
  else ["failed"]
fctd (x, y, sx, sy) == 
  if y~=0 and x rem y = 0 
  then [(x/y)::TUIS, concat [sx, "/", sy]]
  else ["failed"]

)cl prop fctaa
)cl prop fctbb
)cl prop fctcc
)cl prop fctdd

fctaa : (List Any, List Any) -> List Any
fctbb : (List Any, List Any) -> List Any
fctcc : (List Any, List Any) -> List Any
fctdd : (List Any, List Any) -> List Any

fctaa (lx,ly) == 
  if ((lx.1) case String) or ((ly.1) case String) 
  then ["failed"] 
  else fcta (lx.1,ly.1,lx.2,ly.2)
fctbb (lx,ly) == 
  if (lx.1 case String) or (ly.1 case String) 
  then ["failed"] 
  else fctb (lx.1,ly.1,lx.2,ly.2)
fctcc (lx,ly) == 
  if (lx.1 case String) or (ly.1 case String) 
  then ["failed"] 
  else fctc (lx.1,ly.1,lx.2,ly.2)
fctdd (lx,ly) == 
  if (lx.1 case String) or (ly.1 case String) 
  then ["failed"] 
  else fctd (lx.1,ly.1,lx.2,ly.2)

Lopaa := [fctaa, fctbb, fctcc, fctdd]

calculsa (Ln, Lop) ==
  [(Lop.3)((Lop.2)((Lop.1)(Ln.1,Ln.2),Ln.3),Ln.4),      -- ((x % y) % z) % t
    (Lop.2)((Lop.1)(Ln.1,Ln.2),(Lop.3)(Ln.3,Ln.4)),      -- (x % y) % (z % t)
     (Lop.3)((Lop.1)(Ln.1,(Lop.2)(Ln.2,Ln.3)),Ln.4),     -- (x % (y % z)) % t
      (Lop.1)(Ln.1,(Lop.3)((Lop.2)(Ln.2,Ln.3),Ln.4)),    -- x % ((y % z) % t)
       (Lop.1)(Ln.1,(Lop.2)(Ln.2,(Lop.3)(Ln.3,Ln.4)))]   -- x % (y % (z % t))
  
Lnba := [[2::TUIS,"2"],[3::TUIS,"3"],[4::TUIS,"4"],[6::TUIS,"6"]]::List Any
LLop := concat 
 [concat [[[Lopaa.i1, Lopaa.i2, Lopaa.i3] for i1 in 1..4] for i2 in 1..4] 
    for i3 in 1..4] 

res := [[calculs (nbs, lop) for nbs in Lnb] for lop in LLop]
-- set concat concat res 
--  Lopaa)

-- semble planter (pb d'axiom)
--------------------------------------------------------------
L := [2,3,4,6]

RIS := Record (val:Integer, str:String)
--- LR := [construct$RIS(nb, nb::String) for nb in L]  --- plante
LR := [construct(nb, nb::String)@RIS for nb in L]

Lnb1 := concat 
  [concat 
    [concat [[[LR.i1, LR.i2, LR.i3, LR.i4] for i1 in 1..4] for i2 in 1..4]
       for i3 in 1..4] for i4 in 1..4]
Lnb := select (ll +-> test (# set ll = 4), Lnb1)

fcta : (RIS, RIS) -> RIS
fctb : (RIS, RIS) -> RIS
fctc : (RIS, RIS) -> RIS
fctd : (RIS, RIS) -> RIS

fcta (x, y) ==     -- les  => ne marchent pas quand il n'y en a qu'une
  if (x.val = -1) or (y.val=-1) 
  then construct (-1,"failled")@RIS
  else construct (x.val+y.val, concat ["(",x.str, "+", y.str,")"])@RIS
fctb (x, y) == 
  (x.val = -1) or (y.val=-1) => construct (-1,"failled")@RIS
  x.val<y.val => construct (-1,"failled")@RIS
  construct (x.val-y.val, concat ["(",x.str, "-", y.str,")"])@RIS
fctc (x, y) == 
  if (x.val = -1) or (y.val=-1) 
  then construct (-1,"failled")@RIS
  else construct (x.val*y.val, concat ["(",x.str, "*", y.str,")"])@RIS
fctd (x, y) == 
  (x.val = -1) or (y.val=-1) => construct(-1,"failled")@RIS
  (y.val = 0) or (x.val rem y.val ~= 0) => construct(-1,"failled")@RIS
  construct (x.val/y.val, concat ["(",x.str, "/", y.str,")"])@RIS

Lf := [fcta, fctb, fctc, fctd]
Lfct := concat 
 [concat [[[Lf.i1, Lf.i2, Lf.i3] for i1 in 1..4] for i2 in 1..4] 
    for i3 in 1..4] 

calculsUneSerie (Ln, Lop) ==
  [(Lop.3)((Lop.2)((Lop.1)(Ln.1,Ln.2),Ln.3),Ln.4),      -- ((x % y) % z) % t
    (Lop.2)((Lop.1)(Ln.1,Ln.2),(Lop.3)(Ln.3,Ln.4)),      -- (x % y) % (z % t)
     (Lop.3)((Lop.1)(Ln.1,(Lop.2)(Ln.2,Ln.3)),Ln.4),     -- (x % (y % z)) % t
      (Lop.1)(Ln.1,(Lop.3)((Lop.2)(Ln.2,Ln.3),Ln.4)),    -- x % ((y % z) % t)
       (Lop.1)(Ln.1,(Lop.2)(Ln.2,(Lop.3)(Ln.3,Ln.4)))]   -- x % (y % (z % t))
  

-- plante Lf.1 (Record, Record) 
-- appel (Lf.1)(Integer, Integer) marche pas ???

-----------------------------------------------------------------------------
L := [2,3,4,6]

RIS := Record (val:Integer, str:String)
LR := [construct(nb, nb::String)@RIS for nb in L]

Lnb1 := concat 
  [concat 
    [concat [[[LR.i1, LR.i2, LR.i3, LR.i4] for i1 in 1..4] for i2 in 1..4]
       for i3 in 1..4] for i4 in 1..4]
Lnb := select (ll +-> test (# set ll = 4), Lnb1)

fcta := (x, y) +->     -- les  => ne marchent pas quand il n'y en a qu'une
  if (x.val = -1) or (y.val=-1) 
  then construct (-1,"failled")@RIS
  else construct (x.val+y.val, concat ["(",x.str, "+", y.str,")"])@RIS
fctb := (x, y) +-> 
  (x.val = -1) or (y.val=-1) => construct (-1,"failled")@RIS
  x.val<y.val => construct (-1,"failled")@RIS
  construct (x.val-y.val, concat ["(",x.str, "-", y.str,")"])@RIS
fctc := (x, y) +-> 
  if (x.val = -1) or (y.val=-1) <
  then construct (-1,"failled")@RIS
  else construct (x.val*y.val, concat ["(",x.str, "*", y.str,")"])@RIS
fctd := (x, y) +-> 
  (x.val = -1) or (y.val=-1) => construct(-1,"failled")@RIS
  (y.val = 0) or (x.val rem y.val ~= 0) => construct(-1,"failled")@RIS
  construct (x.val/y.val, concat ["(",x.str, "/", y.str,")"])@RIS

Lf := [fcta, fctb, fctc, fctd]
Lfct := concat 
 [concat [[[Lf.i1, Lf.i2, Lf.i3] for i1 in 1..4] for i2 in 1..4] 
    for i3 in 1..4] 

calculsUneSerie (Ln, Lop) ==
  [(Lop.3)((Lop.2)((Lop.1)(Ln.1,Ln.2),Ln.3),Ln.4),      -- ((x % y) % z) % t
    (Lop.2)((Lop.1)(Ln.1,Ln.2),(Lop.3)(Ln.3,Ln.4)),      -- (x % y) % (z % t)
     (Lop.3)((Lop.1)(Ln.1,(Lop.2)(Ln.2,Ln.3)),Ln.4),     -- (x % (y % z)) % t
      (Lop.1)(Ln.1,(Lop.3)((Lop.2)(Ln.2,Ln.3),Ln.4)),    -- x % ((y % z) % t)
       (Lop.1)(Ln.1,(Lop.2)(Ln.2,(Lop.3)(Ln.3,Ln.4)))]   -- x % (y % (z % t))
  

res := [[calculsUneSerie (nb, fct) for nb in Lnb] for fct in Lfct]
res := [{output nb ; [calculsUneSerie (nb, fct) for fct in Lfct]}for nb in Lnb]
ensSol := set concat concat res 
ensVal := set [t.val for t in ensSol]
nbVal := [select (t +-> t.val=x), ensSol]


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
open-axiom-devel mailing list
open-axiom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel

Reply via email to