I find it clearer to break the expression up into parts to see how to do this …

   digi=:10&#.^:_1
   sum5=: 5 = +/"1
   (#~ sum5&digi) 100+i.900                                NB. Now you can see 
the hook more clearly ...
104 113 122 131 140 203 212 221 230 302 311 320 401 410 500

Then if you want to put it altogether again in one line (although I find the 
above clearer) …
   (#~ ([:(5 = +/"1)(10&#.^:_1))) 100+i.900.          NB. I use [: here to 
coerce the function as a hook ([: f g)x becomes same as (f g) x
104 113 122 131 140 203 212 221 230 302 311 320 401 410 500


HTH…/Regards Rob

> On 16 Jan 2019, at 6:12 pm, 'Skip Cave' via Programming 
> <[email protected]> wrote:
> 
> A Quora question asks "List all the three-digit numbers which have the
> property that the sum of their digits is equal to 5"
> 
> I got the answer explicitly, by a straightforward brute force approach::
> 
> a#~5=+/"1]10#.^:_1 a=:100+i.900
> 
> 104 113 122 131 140 203 212 221 230 302 311 320 401 410 500
> 
> 
> How can this be written implicitly?
> 
> 
> Skip
> 
> 
> Skip Cave
> Cave Consulting LLC
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to