Message Boards Message Boards

0
|
4000 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Create a table / an array with conditions?

Posted 6 years ago

Hello everyone,

I'm trying (and failing) to create an array with dimensions {i1,j1,k1,i2,j2,k2}, conditioned to: {i1 + j1 + k1 = n} & {i2 + j2 + k2 = n}, where n is a fixed (given) integer number. In attachment is what I've done so far. Thank you very much!

Attachments:
POSTED BY: Daniel Grun
3 Replies

You can just create a function with inputs i1, j1, k1, i2 , j2, k2 and n to do what you want.

H[n_][i1_, j1_, k1_, i2_, j2_, k2_ ] := If [  i1 + j1 +k1 = n  && i2 + j2  +k2, (* Do something *), (* Do something *)]

You can even parametrize the tasks of the conditional statement in the above code.

POSTED BY: Ta'a Nwa Dombou

As far as I know it is a bit tricky using indices 0 accessing Table-elements

In[22]:= tt = Table[i, {i, 0, 3}]
tt[[0]]
tt[[1]]

Out[22]= {0, 1, 2, 3}

Out[23]= List

Out[24]= 0

Moreover your notebook contains a typo (Deletecases).

Is it (see notebook attached) this what you want? But then you must take into account that H [[ 2, .... ]] refers to i1 = 1.

Attachments:
POSTED BY: Hans Dolhaine
Posted 6 years ago

Actually, that's not what I was looking for - which I've already figured out. Thank you, anyway!

POSTED BY: Daniel Grun
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract