<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>Hi all</div>
<div><br>
</div>
<div>I wonder if anyone has any suggestions for a generic way of writing functions that deal with input/output arrays which may have different numbers of dimensions, e.g.</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>function generic_example(input:numeric)</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>begin</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> output = some_subset_of_(input)</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> </div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> return(output)<span class="Apple-tab-span" style="white-space:pre">
</span></div>
<div> end</div>
<div><br>
</div>
<div>where input/output might be 1, 2, 3, 4 or more dimensions, and so a different line is needed to do the subsetting step.</div>
<div><br>
</div>
<div>At the moment I just use nested 'if' statements based on the rank of the array (where rank is the number of dimensions, i.e. dimsizes(dim sizes(input)), and this works fine. But, it does not make for particularly 'clean' or efficient code, so I wonder
if anyone has any nicer ways of doing this.</div>
<div><br>
</div>
<div>Many thanks</div>
<div><br>
</div>
<div>Will</div>
<p style="font-size:10pt; line-height:10pt; calibri"><br>
<br>
University of Tasmania Electronic Communications Policy (December, 2014). <br>
This email is confidential, and is for the intended recipient only. Access, disclosure, copying, distribution, or reliance on any of it by anyone outside the intended recipient organisation is prohibited and may be a criminal offence. Please delete if obtained
in error and email confirmation to the sender. The views expressed in this email are not necessarily the views of the University of Tasmania, unless clearly intended otherwise.
</p>
</body>
</html>