You should theoretically allow bases beyond a radix of 16. I see your switch only goes to F/f, when it should go to Z/z. To make it easier on yourself, check whether it's a letter and uppercase and convert to lowercase if so. Then do the standard equation you are using to convert it to it's decimal representation.
My two cents.
Consider it? If it's a matter of performance (and I'm not expert on the matter), in your snippet you're iterating so much more than necessary. Consider your 2x3x4 example. Mine would iterate (234) or 24 times. In your case, you loop 2 + (23) + (23*4) or 32 times. And these are just small dimensions. Again, I'm not too knowledgeable but surely you can see the optimization in this.
This is where I remember seeing his script a long time ago.
$getsource: http://forum.swiftirc.net/viewtopic.php?f=74&t=24161
Nice script by the way.
I'm not sure if this was done more out of demonstrating the code, but why not take:
double ***ptr3;
ptr3 = new double**[2];
for( int i = 0 ; i < 2 ; i++)
{
ptr3[i] = new double*[3];
}
for( int i = 0 ; i < 2 ; i++)
{
for( int j = 0 ; j < 3 ; j++)
{
ptr3[i][j] = new double[4];
}
}
for( int i = 0 ; i < 2 ; i++)
{
for( int j = 0 ; j < 3 ; j++)
{
for( int k = 0 ; k < 4 ; k++)
{
ptr3[i][j][k] = ( i * 3 + j ) * 4.1 + k * 0.1;
}
}
}
And make it:
double ***ptr3;
ptr3 = new double**[2];
for( int i = 0 ; i < 2 ; i++)
{
ptr3[i] = new double*[3];
for( int j = 0 ; j < 3 ; j++)
{
ptr3[i][j] = new double[4];
for( int k = 0 ; k < 4 ; k++)
{
ptr3[i][j][k] = ( i * 3 + j ) * 4.1 + k * 0.1;
}
}
}
I'm pretty sure this is a rip (apologies if not). I've had this little snippet in my remotes that I got from someone for a long time:
alias np {
if (!$com(itunes)) { .comopen itunes iTunes.Application }
if ($com(CurrentTrack)) { .comclose CurrentTrack }
noop $com(itunes,CurrentTrack,3,dispatch* CurrentTrack)
noop $com(CurrentTrack,Artist,3)
var %artist $com(CurrentTrack).result
noop $com(CurrentTrack,Time,3)
var %time $com(CurrentTrack).result
noop $com(CurrentTrack,Name,3)
var %name $com(CurrentTrack).result
noop $com(CurrentTrack,BitRate,3)
var %bitrate $com(CurrentTrack).result
me Now Playing: Artist: %artist Track: %name Time: %time Bitrate: %bitrate
.comclose CurrentTrack
}
Well his is organized so that you can supply any number of parameters, i.e. $vget(blah, test, foo, fah, words,46).
However, I agree in that a loop isn't necessary. Here was my take on it:
alias vget {
tokenize 32 $($1-,2)
var %d $iif($($+($,$0),2) != 0,$v1)
var %e $($+(%,$replace($($iif(%d,$+($,1-,$calc($0 -1)),$+($,1-,$0)),2), $chr(32), $chr(%d))),2)
if (%e) return %e
else return Variable not set.
}
Though as you mentioned, you made yours for readability :V
Here was my take on this:
alias digTimeFormat return ddd/HH:nn:ss TT
alias digTimeFontSize return 10
alias timebar {
if (!$isdir(digTime)) mkdir digTime
if ($toolbar(digTime)) { echo -s Toolbar already loaded | halt }
window -hp +d @_digTimeWin -1 -1 $calc($width($asctime($ctime,$digTimeFormat), Tahoma, $digTimeFontSize) + 10) $calc($height($asctime($ctime,$digTimeFormat), Tahoma, digTimeFontSize))
.timerDigTime 0 1 updateDigTimeWin Digital Time
}
alias -l updateDigTimeWin {
clear @_digTimeWin
drawText -r @_digTimeWin $rgb(0,204,0) Tahoma $digTimeFontSize 3 3 $asctime($ctime, $digTimeFormat)
updateDigTimeToolbar
}
alias -l updateDigTimeToolBar {
drawSave @_digTimeWin digTime\digTime.jpg
if ($toolbar(digTime)) toolbar -p digTime "digTime\digTime.jpg"
else toolbar -a digTime $qt($1-) "digTime\digTime.jpg"
}
alias timeBarOff {
toolbar -d digTime
window -c @_digTimeWin
.timerDigTime off
}