From 83c73c8a9c53d892a98feefce6a683f63e76e6cb Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Sun, 23 Nov 2025 22:43:45 +0100 Subject: Solution to task 2 in J --- challenge-348/jo-37/j/ch-1.ijs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 challenge-348/jo-37/j/ch-1.ijs diff --git a/challenge-348/jo-37/j/ch-1.ijs b/challenge-348/jo-37/j/ch-1.ijs new file mode 100755 index 0000000000..6a1a95daa5 --- /dev/null +++ b/challenge-348/jo-37/j/ch-1.ijs @@ -0,0 +1,36 @@ +#!/usr/local/bin/jconsole + +Vows =: 'aeiouAEIOU' +halve =: {{((-.(2|#y))*(<. -: #y))({. ; }.)y}} +countvows =: {{+/ (#Vows) > Vows i. y}} +stringalike =: {{-. 0 = (=/ * */) countvows "1 > halve >y}} + +Ex =: cutopen 0 : 0 +textbook +book +AbCdEfGh +rhythmmyth +UmpireeAudio +) + +3 : 0 > 2}. ARGV +if. + 1 = # y +do. + echo stringalike 0 { y +elseif. + 0 = # y +do. + try. + assert (0 1 1 0 0) = stringalike "0 Ex + echo 'tests succeeded' + catch. + echo 'tests failed ' + end. +else. + echo 'Call "./ch-1.ijs STR" to process string' + echo 'or "./ch-1.ijs" to run the examples' +end. +) + +exit '' -- cgit