How to use array_quicksort on @?

See:

https://github.com/githwxi/ATS-Postiats-test/blob/master/contrib/hwxi/TEST10/test14.datsOn Friday, July 24, 2015 at 8:01:48 AM UTC-4, Kiwamu Okabe wrote:

Hi all,

How to use array_quicksort on @[int][N]?

I’m trying to use array_quicksort with such like following code.

https://github.com/jats-ug/practice-ats/blob/61c3f34dc478e4f394b5a9087225f81eac65c47a/array_quicksort/main.dats

implement main0 () = { 
  var arr: @[int][N] 
  val () = arr[0] := 5 
  val () = arr[1] := 4 
  val () = arr[2] := 3 
  implement array_quicksort$cmp<int> (x, y) = compare (x, y) 
  val () = array_quicksort<int> (arr, i2sz N) 
} 

However, it causes following error.

$ patscc main.dats 
/home/kiwamu/src/practice-ats/array_quicksort/main.dats: 374(line=15, 
offs=34) -- 377(line=15, offs=37): error(3): the dynamic expression 
cannot be assigned the type [S2Etyarr(S2Eapp(S2Ecst(INV); 
S2Ecst(int)); S2EVar(4391))]. 
/home/kiwamu/src/practice-ats/array_quicksort/main.dats: 374(line=15, 
offs=34) -- 377(line=15, offs=37): error(3): mismatch of static terms 
(tyleq): 
The actual term is: S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
S2Eextkind(atstype_int))) 
The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int)) 

What does “S2Etop” mean?

Thank’s,

Kiwamu Okabe at METASEPI DESIGN

What does “S2Etop” mean?

S2Etop means “uninitialized”. For instance, S2Etop(int) is for
uninitialized integers.On Friday, July 24, 2015 at 2:06:58 PM UTC-4, gmhwxi wrote:

See:

https://github.com/githwxi/ATS-Postiats-test/blob/master/contrib/hwxi/TEST10/test14.dats

On Friday, July 24, 2015 at 8:01:48 AM UTC-4, Kiwamu Okabe wrote:

Hi all,

How to use array_quicksort on @[int][N]?

I’m trying to use array_quicksort with such like following code.

https://github.com/jats-ug/practice-ats/blob/61c3f34dc478e4f394b5a9087225f81eac65c47a/array_quicksort/main.dats

implement main0 () = { 
  var arr: @[int][N] 
  val () = arr[0] := 5 
  val () = arr[1] := 4 
  val () = arr[2] := 3 
  implement array_quicksort$cmp<int> (x, y) = compare (x, y) 
  val () = array_quicksort<int> (arr, i2sz N) 
} 

However, it causes following error.

$ patscc main.dats 
/home/kiwamu/src/practice-ats/array_quicksort/main.dats: 374(line=15, 
offs=34) -- 377(line=15, offs=37): error(3): the dynamic expression 
cannot be assigned the type [S2Etyarr(S2Eapp(S2Ecst(INV); 
S2Ecst(int)); S2EVar(4391))]. 
/home/kiwamu/src/practice-ats/array_quicksort/main.dats: 374(line=15, 
offs=34) -- 377(line=15, offs=37): error(3): mismatch of static terms 
(tyleq): 
The actual term is: S2Etop(knd=0; S2Eapp(S2Ecst(g0int_t0ype); 
S2Eextkind(atstype_int))) 
The needed term is: S2Eapp(S2Ecst(g0int_t0ype); S2Eextkind(atstype_int)) 

What does “S2Etop” mean?

Thank’s,

Kiwamu Okabe at METASEPI DESIGN

You could use the following style:

implement
main0 () =
{

var A = @[int]3 // initializing A with 0’s
val () = A[0] := 1
val () = A[1] := 2
val () = A[2] := 3

}

Or you could use some unsafe features.On Friday, July 24, 2015 at 10:43:08 PM UTC-4, Kiwamu Okabe wrote:

On Sat, Jul 25, 2015 at 11:39 AM, gmhwxi <gmh...@gmail.com <javascript:>> wrote:

   var arr: @[int][N] 
   val () = arr[0] := 5 
   val () = arr[1] := 4 
   val () = arr[2] := 3 

The problem with this style is that the compiler does not
know what type should be assigned to ‘arr’ after ‘arr[0] := 5’:

At this point,‘arr’ is only partially initialized.

I think I understand it.
However, how should very large array be initialized?

Thank’s,

Kiwamu Okabe at METASEPI DESIGN

See:

https://github.com/githwxi/ATS-Postiats-test/blob/master/contrib/hwxi/TEST10/test14.dats

It works.

Following codes is different?
I think both initialize arr at first.

   var arr: @[int][N] 
   val () = arr[0] := 5 
   val () = arr[1] := 4 
   val () = arr[2] := 3 

The problem with this style is that the compiler does not
know what type should be assigned to ‘arr’ after ‘arr[0] := 5’:

At this point,‘arr’ is only partially initialized.