A simple question. 
Author Message
 A simple question.

Hi, there:
        The origin array is an int array a=0 321 324 291
        I want output it in a txt file like this:
        0,321,324,291,

        So I can include it  in a .c file :)
        It seemed that apl do not provide function such as printf.
        I use APL 11, which has source :) .
        Or is apl intended to not be a general purpose language , like C?

Thank in advance.
Deng Hao
Beijing, China

        I like APL.



Sat, 29 May 2004 15:37:32 GMT  
 A simple question.

Quote:

>        The origin array is an int array a=0 321 324 291
>        I want output it in a txt file like this:
>        0,321,324,291,
>        So I can include it  in a .c file :)
>        It seemed that apl do not provide function such as printf.
>        I use APL 11, which has source :) .
>        Or is apl intended to not be a general purpose language , like C?

I don't know the capabilities of APL 11, but I would suspect that you can do
the following:

      z <- {format} a
      z[(z=' ')/{iota}{rho}z] <- ','

The first statement creates a string where numbers are separated by spaces
(this is the normal representation of a list of numbers in APL). The second
statement replaces all spaces by commas. You can catenate a trailing comma
if you need it.

I'm not sure I agree that an exact equivalent of "printf" is included in the
definition of "general purpose" :). Most APL systems have significantly more
powerful formatting tools available!

/ Morten



Sat, 29 May 2004 19:14:56 GMT  
 A simple question.
Try:

({flatten}({thorn}{each}a),{each}','){not}' '

If you do not want the trailing comma, put {neg}1{drop} in front of the
above code.

geo


Quote:
> Hi, there:
>         The origin array is an int array a=0 321 324 291
>         I want output it in a txt file like this:
>         0,321,324,291,

>         So I can include it  in a .c file :)
>         It seemed that apl do not provide function such as printf.
>         I use APL 11, which has source :) .
>         Or is apl intended to not be a general purpose language , like C?

> Thank in advance.
> Deng Hao
> Beijing, China

>         I like APL.



Sun, 30 May 2004 10:51:17 GMT  
 A simple question.

Quote:

> Try:

> ({flatten}({thorn}{each}a),{each}','){not}' '

> If you do not want the trailing comma, put {neg}1{drop} in front of the
> above code.

> geo

George, what is "flatten", its not in my APL Symbols list?

Fred



Sun, 30 May 2004 20:34:51 GMT  
 A simple question.

Quote:
> > Try:

> > ({flatten}({thorn}{each}a),{each}','){not}' '

> > If you do not want the trailing comma, put {neg}1{drop} in front of
> > the above code.

> > geo

> George, what is "flatten", its not in my APL Symbols list?

I am not George but I'll dare a reply. I think it's "enlist" or
"monadic-epsilon"...
--

Homepage: http://come.to/wildheart/

<<<All I Ever Learned, I Learned From Anime: ---
   Never trust a huge corporation.>>>



Sun, 30 May 2004 21:29:12 GMT  
 A simple question.
Does anybody know whether APL11 is a "second generation" APL system which
can execute this type of solution?

/ Morten

Quote:
-----Original Message-----

Lanzavecchia
Sent: 12. december 2001 14:17

Subject: Re: A simple question.

> > Try:

> > ({flatten}({thorn}{each}a),{each}','){not}' '

> > If you do not want the trailing comma, put {neg}1{drop} in front of
> > the above code.

> > geo

> George, what is "flatten", its not in my APL Symbols list?

I am not George but I'll dare a reply. I think it's "enlist" or
"monadic-epsilon"...
--

Homepage: http://come.to/wildheart/

<<<All I Ever Learned, I Learned From Anime: ---
   Never trust a huge corporation.>>>



Sun, 30 May 2004 22:32:51 GMT  
 A simple question.

Quote:
> > > Try:

> > > ({flatten}({thorn}{each}a),{each}','){not}' '

> > > If you do not want the trailing comma, put {neg}1{drop}
> in front of
> > > the above code.

> > > geo

> > George, what is "flatten", its not in my APL Symbols list?

> I am not George but I'll dare a reply. I think it's "enlist" or
> "monadic-epsilon"...
> Does anybody know whether APL11 is a "second generation" APL system
> which can execute this type of solution?

I am 99% sure that APL-11 is not second generation.
--

Homepage: http://www.*-*-*.com/

<<<All I Ever Learned, I Learned From Anime: ---
   No matter how much {*filter*} is lost, no one can die from a nosebleed.>>>



Sun, 30 May 2004 22:39:27 GMT  
 A simple question.

Quote:

> I am not George but I'll dare a reply. I think it's "enlist" or
> "monadic-epsilon"...

Note that this is an APL2 thing.  I don't know if other implementations
have it.

Ted



Mon, 31 May 2004 01:50:45 GMT  
 A simple question.

Quote:

> Does anybody know whether APL11 is a "second generation" APL system which
> can execute this type of solution?

I doubt it but in an implementation without nested arrays, {flatten} and
{ravel} are equivalent and format has been around for quite a while.  If
you need it, I might be able to dig out or re-create SQUISH.  I wrote
SQUISH in 1967 to replace strings of blanks with a single blank in a
character vector.  It also eliminated leading and trailing blanks.  Then
      a{is}SQUISH{format},a
      a[(a=' ')/{iota}{rho}a]{is}','

Ted



Mon, 31 May 2004 01:50:49 GMT  
 A simple question.


Quote:
> I am 99% sure that APL-11 is not second generation.

Agree. I am 1 % unsure that APL-11 is not second generation.
Old APL+PC's work best together with the FinnAPL idioms at:
http://www.pyr.fi/apl/index.htm

/ Tomas



Mon, 31 May 2004 05:05:43 GMT  
 A simple question.
O.K., O.K., so I make up a name now and then, don't we all?

My son calls it "Super Ravel", but it's actually "enlist"
the monadic epsilon operator that strips away nesting
to the lowest possible depth.

geo


Quote:

> > Try:

> > ({flatten}({thorn}{each}a),{each}','){not}' '

> > If you do not want the trailing comma, put {neg}1{drop} in front of the
> > above code.

> > geo

> George, what is "flatten", its not in my APL Symbols list?

> Fred



Mon, 31 May 2004 08:58:10 GMT  
 A simple question.
You can remove the {each} between {thorn} and "a", it's not needed.
-andy



Quote:
> Try:

> ({flatten}({thorn}{each}a),{each}','){not}' '

> If you do not want the trailing comma, put {neg}1{drop} in front of the
> above code.

> geo



> > Hi, there:
> >         The origin array is an int array a=0 321 324 291
> >         I want output it in a txt file like this:
> >         0,321,324,291,

> >         So I can include it  in a .c file :)
> >         It seemed that apl do not provide function such as printf.
> >         I use APL 11, which has source :) .
> >         Or is apl intended to not be a general purpose language , like
C?

> > Thank in advance.
> > Deng Hao
> > Beijing, China

> >         I like APL.



Mon, 31 May 2004 09:15:33 GMT  
 A simple question.

Quote:


> > I am not George but I'll dare a reply. I think it's "enlist" or
> > "monadic-epsilon"...

> Note that this is an APL2 thing.  I don't know if other implementations
> have it.

Both Dyalog and APL2000 do a pretty credible job of emulating APL2
if you set []ML/[]CL(?).  I know that Dyalog has enlist, and I -think-
I recall that APL200 does also.


Mon, 31 May 2004 10:55:04 GMT  
 A simple question.

Quote:

> Does anybody know whether APL11 is a "second generation" APL system which
> can execute this type of solution?

> / Morten

It is a first generation APL.  People considering using
APL11 may want to investigate Branko Bratkovic's openAPL,
which is an update of APL11 and supports the APL character
set.

Both versions are available at
ftp://sunsite.unc.edu/pub/Linux/devel/lang/apl

--- Brian



Mon, 31 May 2004 22:30:06 GMT  
 A simple question.
"Ted Edwards" wrote ...

Quote:

> > Does anybody know whether APL11 is a "second generation" APL system
which
> > can execute this type of solution?

> I doubt it but in an implementation without nested arrays, {flatten} and
> {ravel} are equivalent and format has been around for quite a while.  If
> you need it, I might be able to dig out or re-create SQUISH.  I wrote
> SQUISH in 1967 to replace strings of blanks with a single blank in a
> character vector.  It also eliminated leading and trailing blanks.  Then
>       a{is}SQUISH{format},a
>       a[(a=' ')/{iota}{rho}a]{is}','

SQUISH -- under the name of TAILOR -- was one of the first utilities I
learned.  I'm sure it's in the FinnAPL idioms.

I thnk it's interesting to compare the two "old-fashioned" APL solutions.
You use SQUISH to insure that there's exactly one blank between numbers,
then replace those blanks with commas.  In my alternative (a separate
post) I first add the commas by formatting the numbers as a matrix, then
ravel and remove *all* blanks.

        /Jim Lucas



Wed, 02 Jun 2004 17:18:44 GMT  
 
 [ 19 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Question in french (a simple question, very simple)

2. Simple Question seeks simple answer

3. Stumper Question for me: simple question for this group -exponential and logs

4. HTML simple question ?

5. J (simple) questions

6. simple question

7. simple question

8. Concatenating strings..simple question.

9. What is APL\11 (A Simple Question)

10. A Simple Question

11. Fw: What is APL\11 (A Simple Question)

12. A very simple question on SED or AWK for a GURU, and an enjoyable problem

 

 
Powered by phpBB® Forum Software