After a few months off I'm back working through some problems in the Daylog APL 
challenge as a way of learning J. One problem is to shorten a message yet 
retain most readability by removing interior vowels from words. Here's my 
rather verbose solution to this problem:
splitToWords =: ' ' & splitstringjoinWords =: ' ' & joinstringtrimVowel =: -. & 
'AEIOUaeiou'innerPart =: }. @: }:trimInnerVowels =: {. , (trimVowel @: 
innerPart) , {:trimmable =: (> &2) @: #trimWord =: ] ` trimInnerVowels @. 
trimmable 
makeTweetable =: joinWords @: (trimWord &. >) @: splitToWords

The verb joinWords is, semantically, the inverse of splitToWords and I'd like 
to express that in my solution. I know that J can automatically find the 
inverse of some user defined verbs. However, in this case it fails:
joinWords =: splitToWords ^: _1
   t┌─┬──┬──┬─────┐│i│am│so│happy│└─┴──┴──┴─────┘   joinWords t|domain error: 
joinWords
My guess is that there isn't a deductible relationship between the script 
functions I use, but I'd love to understand how function inverse really works. 
In particular I'd like to learn more about:
1. In what cases can J find the inverse of a verb?2. Is there any way for me, 
as a user, to specify or declare an inverse to a specific verb?
I'm also pretty sure that my solution above can be simplified a lot. I'd be 
happy for any feedback on the code.
Thanks in advance! 
--  Homepage: www.adamtornhill.com  Twitter: @AdamTornhill 
The History of your Code will decide its Future: https://codescene.io/Your Code 
as a Crime Scene: 
https://pragprog.com/book/atcrime/your-code-as-a-crime-sceneLisp for the Web:  
https://leanpub.com/lispwebPatterns in C: https://leanpub.com/patternsinc
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to