The original question is about composing functions, but if you are really
trying to count characters there are much more efficient ways.  For example:

   x=: 'abcdefghijklmnopqrstuvwxyz'
   y=: a.{~ 1e6 ?@$ #a.
   c=: <: (#x) {. #/.~ x,y
   $c
26
   c
4019 3829 3893 3912 3889 4020 3965 3936 3960 3918 3913 3945 3936 3901 3874
3919 3881 3974 3903 3840 3838 3924 3883 3982 3823 3938
   +/"1 x=/y
4019 3829 3893 3912 3889 4020 3965 3936 3960 3918 3913 3945 3936 3901 3874
3919 3881 3974 3903 3840 3838 3924 3883 3982 3823 3938

x is the domain of interest.  y is the sample text.  c are the counts of
the domain of interest in the sample text.

   ts=: 6!:2, 7!:2@]
   ts '+/"1 x=/y'
0.0281558 3.35583e7
   ts '<: (#x) {. #/.~ x,y'
0.00252141 1.05894e6
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to