diff options
| -rwxr-xr-x | challenge-348/jo-37/j/ch-2.ijs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/challenge-348/jo-37/j/ch-2.ijs b/challenge-348/jo-37/j/ch-2.ijs new file mode 100755 index 0000000000..03748ad55d --- /dev/null +++ b/challenge-348/jo-37/j/ch-2.ijs @@ -0,0 +1,30 @@ +#!/usr/local/bin/jconsole + +ConvertTime =: {{+/ 24 4 3 5 #: (24 * 60) | -~/ 24 60 #. > y}} +NB. ConvertTime =: +/ 24 4 3 5 #: (24 * 60) | -~/ (24 60)&#. + +3 : 0 > 2}. ARGV +if. + 2 = # y +do. + TR =: '([0-9]+):([0-9]+)' + try. + echo ConvertTime ". > {{((TR; 1 2) rxmatch y) rxfrom y}} "1 y + catch. + echo 'invalid arguments', 13!:12'' + end. +elseif. + 0 = # y +do. + echo ConvertTime 2 30; 2 45 + echo ConvertTime 11 55; 12 15 + echo ConvertTime 9 0; 13 0 + echo ConvertTime 23 45; 0 30 + echo ConvertTime 14 20; 15 25 +else. + echo 'Call "./ch-2.ijs H1:M1 H2:M2" to process times' + echo 'or "./ch-2.ijs" to run the examples' +end. +) + +exit '' |
