[Jprogramming] quote problem
Don Guinn
donguinn at gmail.com
Mon Feb 13 07:09:00 HKT 2012
Yes. I really think this is a crazy idea to forget. Quotes don't really
need to be doubled except if the text is to be executed.
On Sunday, February 12, 2012, Raul Miller <rauldmiller at gmail.com> wrote:
> On Sun, Feb 12, 2012 at 1:34 PM, Don Guinn <donguinn at gmail.com> wrote:
>> I think this is close to what you want. It doubles embedded quotes and
>> ignores leading and trailing quotes if present. That way one can still
>> enter a string which is really supposed have a quote at the begining or
>> end. The only real problem is that if one wanted to start or end with a
>> quote but forgot to add one extra.
>>
>> quotes=:3 : 0
>> '''' quotes y NB. Default left argument is quote.
>> :
>> 'l r'=.x=({.,{:)y NB. Remove leading and trailing quotes if present.
>> s=.l}.(-r)}.y
>> s=.s#~>:x=s NB. Double quotes.
>> x,s,x NB. Put leading and trailing quotes back.
>> )
>
> quotes prompt' '
> 'oh', 'really?'
> 'oh'', ''really?'
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
--
More information about the Programming
mailing list