## 703 Reputation

17 years, 308 days

## Here is a version that handles ties acco...

Here is a version that handles ties according to the Wikipedia description of the card game.

Card_Game,War.mw

---

Duncan

## Here is a version that handles ties acco...

Here is a version that handles ties according to the Wikipedia description of the card game.

Card_Game,War.mw

---

Duncan

## sort by the third column as follows...

Based on Robert Israel's post, the Array T can be sorted by its third column as follows:

`A := sort(Array(1..16, i->T[i]), (a,b) -> (a[3]>=b[3]));Array(ArrayDims(T),(i,j)->A[i][j]);`

## sort by the third column as follows...

Based on Robert Israel's post, the Array T can be sorted by its third column as follows:

`A := sort(Array(1..16, i->T[i]), (a,b) -> (a[3]>=b[3]));Array(ArrayDims(T),(i,j)->A[i][j]);`

## @goli  One way of doing this is to...

One way of doing this is to store the data in an Array then write the array to a file.

`T := Array(1..16, 1..3):idx := 1:for m from 1 by 1 to 4 do  for n from 1 by 1 to 4 do    alpha := m+n;    T[idx, 1] := m;    T[idx, 2] := n;    T[idx, 3] := alpha;    idx := idx + 1  od;od;writedata("test.dat", convert(T, array), integer);`

## @goli  One way of doing this is to...

One way of doing this is to store the data in an Array then write the array to a file.

`T := Array(1..16, 1..3):idx := 1:for m from 1 by 1 to 4 do  for n from 1 by 1 to 4 do    alpha := m+n;    T[idx, 1] := m;    T[idx, 2] := n;    T[idx, 3] := alpha;    idx := idx + 1  od;od;writedata("test.dat", convert(T, array), integer);`

## Call print within the inner loop...

@goli The easiest way to do what you ask is to call print within the inner loop

```for m from 1 by 1 to 4 do
for n from 1 by 1 to 4 do
alpha := m+n;
print(m,n,alpha);
od;
od;
```

With printlevel := 1; (the default) the output from the alpha := m+n; statement won't appear.

## Call print within the inner loop...

@goli The easiest way to do what you ask is to call print within the inner loop

```for m from 1 by 1 to 4 do
for n from 1 by 1 to 4 do
alpha := m+n;
print(m,n,alpha);
od;
od;
```

With printlevel := 1; (the default) the output from the alpha := m+n; statement won't appear.

## Use three variables on left hand side...

Use three variables on left hand side of assignment

a, b, c := test(alpha, beta);

---

Duncan

## Use three variables on left hand side...

Use three variables on left hand side of assignment

a, b, c := test(alpha, beta);

---

Duncan

## I experience the same problem...

I experience the same problem, but only with the Standard Worksheet in Document Mode, and only when I press Shift+Enter to add newlines in the declaration of the for loop. If the for loop is all on one line without Shift+Enter then the error doesn't manifest itself. I'm using Maple 12.

---

Duncan

## I didn't realise that it happened random...

@sasomao Sorry, I didn't realise that it happened randomly. I was thinking that you were running the same script on different machines and that it failed on one machine, but not on another. This made me think that perhaps a problem with an external library was to blame.

## I didn't realise that it happened random...

@sasomao Sorry, I didn't realise that it happened randomly. I was thinking that you were running the same script on different machines and that it failed on one machine, but not on another. This made me think that perhaps a problem with an external library was to blame.

## Importing Quotes and Counting 7s in para...

@alex_01 Here are two worksheets that perform the tasks in parallel. Both use Threads not Tasks. I'm using Maple 12 which doesn't support Tasks.

Counting_7s_with_Thr.mw

## Importing Quotes and Counting 7s in para...

@alex_01 Here are two worksheets that perform the tasks in parallel. Both use Threads not Tasks. I'm using Maple 12 which doesn't support Tasks.

Counting_7s_with_Thr.mw

 1 2 3 4 Page 3 of 4
﻿