[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Not a bug, need help coding search&replace on a vector

From: Christian Robert
Subject: Re: [Bug-apl] Not a bug, need help coding search&replace on a vector
Date: Tue, 21 Jun 2016 22:19:41 -0400
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1

Well, that was not exactly what I was seeking (condense), but, that "toronto 
looks like a very interesting piece of code/functions ...

deciphering/decoding/understanding each one should enlighten me on apl 
operators/data and usage.

I will look at it.



On 2016-06-21 14:49, Fred Weigel wrote:
Christian Robert

For this, try the "toronto toolkit" in our bits&pieces.

There is a function "condense"

' ' condense '  a b   c d  '

a b c d

Which is what you want (I think). Uses ∆db (delete blanks). Preferable
to get from the toolkit -- functions reproduced below.

∇y←d condense v;b
 ⍝remove redundant blanks and blanks around characters specified in <d>
 ⍝.d 1985.
 ⍝.e 'apple,betty,cat,,dog' = ',' condense '  apple, betty, cat, , dog'
 ⍝.k delete-characters
 ⍝.t 1992.
 ⍝.v 1.1
 ⍝v is character vector (rank 1) only
 ⍝remove leading, trailing, and multiple internal blanks
 ⍝remove blanks around characters specified in <d>
 ⍝e.g. if <d> =<,>, blanks are removed around commas in 'a , b , d'
 y←(∼(y=' ')∧(1⌽b)∨¯1⌽b)/y

∇y←∆db v;b
 ⍝delete blanks (leading, trailing and multiple) from v (rank 0 - 2)
 ⍝.e 'apple betty cat' = ∆db '  apple  betty  cat  '
 ⍝.k delete-characters
 ⍝.v 1.1
 →((0 1 2=⍴⍴v),1)/l1,l1,l2,err1
 b←' '≠v←' ',v
 b←∨⌿' '≠v←' ',v
 y←0 1↓(b∨1⌽b)/v
 err1:⎕←'∆db rank error'

reply via email to

[Prev in Thread] Current Thread [Next in Thread]