f0=: 4 : '(I.x)</.y'
   f1=: 4 : '((i.#y) e. +/\0,x) <;.1 y'

   x=: 1+1e4 [EMAIL PROTECTED] 100
   y=: t {~ (+/x) [EMAIL PROTECTED] #t=. 'barack obama'
   
   x (f0 -: f1) y 
1
   ts=: 6!:2 , 7!:[EMAIL PROTECTED]

   ts 'x f0 y'
0.0700156 1.09591e7
   ts 'x f1 y'
0.00778395 4.20992e6



----- Original Message -----
From: [EMAIL PROTECTED]
Date: Tuesday, November 4, 2008 20:47
Subject: [Jprogramming] cut on length
To: [email protected]

> Hello,
> 
> I've been using J for a while, and to my great shame, I can't 
> wrap my
> head around this one. This is supposed to be easy. Maybe I'm 
> just tired.
> 
> Excuses aside, this is what I want to do.
> 
> Given vector "lengths" containing n integers, and variable "tobecut",
> either a vector of characters or numbers. And given that 
> (+/lengths) =
> #tobecut.
> 
> I want a verb v which will cut "tobecut" by length.
> 
> For example:
> 
>    lengths =: 4 2 5
>    tobecut =: 'abcdefghijk'
> 
>    lengths v tobecut
> +----+--+-----+
> |abcd|ef|ghijk|
> +----+--+-----+
> 
> Of course, the fastest, the better.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to