Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.advocacy > #375257 > unrolled thread

Ping sbd: another programming challenge for your developmentally challenged children

Started byDFS <nospam@dfs.com>
First post2016-10-06 11:42 -0400
Last post2016-10-07 11:10 -0700
Articles 20 on this page of 109 — 20 participants

Back to article view | Back to comp.os.linux.advocacy


Contents

  Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-06 11:42 -0400
    Re: Ping sbd: another programming challenge for your developmentally challenged children Adlbifhr Mjduhgfks <am@random.us> - 2016-10-06 20:00 +0000
      Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-06 19:31 -0400
        Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-07 00:20 +0000
          Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-06 20:55 -0400
            Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-07 01:04 +0000
              Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-06 22:11 -0400
                Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-07 02:19 +0000
                  Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-06 23:20 -0400
                    Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-07 03:33 +0000
                      Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-07 00:02 -0400
                        Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-07 04:22 +0000
                          Re: Ping sbd: another programming challenge for your developmentally challenged children fr314159@gmail.com - 2016-10-07 08:08 -0700
                            Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-07 10:42 -0500
                              Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-08 03:13 +0000
                                Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-08 03:19 +0000
                                  Re: Ping sbd: another programming challenge for your developmentally challenged children Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-10-08 05:37 -0400
                                    Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 07:09 -0500
                                      Re: Ping sbd: another programming challenge for your developmentally challenged children Melzzzzz <mel@zzzzz.com> - 2016-10-10 14:11 +0200
                                    Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 07:37 -0500
                                      Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-10 16:56 +0000
                                  Re: Ping sbd: another programming challenge for your developmentally challenged children Silver Slimer <.m@nsn.s> - 2016-10-08 10:26 -0400
                                    Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-08 10:48 -0400
                                      Re: Ping sbd: another programming challenge for your developmentally challenged children Steve Carroll <fretwizzer@gmail.com> - 2016-10-08 07:58 -0700
                                      Re: Ping sbd: another programming challenge for your developmentally challenged children Silver Slimer <.m@nsn.s> - 2016-10-08 15:04 -0400
                                        Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-09 10:24 -0400
                                    Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-08 15:28 +0000
                                      Re: Ping sbd: another programming challenge for your developmentally challenged children Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-10-08 15:41 -0400
                                        Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-08 19:57 +0000
                                          Re: Ping sbd: another programming challenge for your developmentally challenged children Silver Slimer <.m@nsn.s> - 2016-10-08 17:23 -0400
                                Re: Ping sbd: another programming challenge for your developmentally challenged children Silver Slimer <.m@nsn.s> - 2016-10-08 10:24 -0400
                                Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-08 10:44 -0600
                                  Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-08 17:11 +0000
                                    Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-08 13:46 -0600
                                      Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-08 20:01 +0000
                                        Re: Ping sbd: another programming challenge for your developmentally challenged children ronb <ronb02NOSPAM@gmail.com> - 2016-10-08 23:23 +0000
                                          Re: Ping sbd: another programming challenge for your developmentally challenged children Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-10-08 20:43 -0400
                                            Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-09 01:15 +0000
                                          Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-09 01:13 +0000
                                            Re: Ping sbd: another programming challenge for your developmentally challenged children ronb <ronb02NOSPAM@gmail.com> - 2016-10-09 02:08 +0000
                                              Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-09 02:13 +0000
                                              Re: Ping sbd: another programming challenge for your developmentally challenged children Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-10-09 08:15 -0400
                                                Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 07:27 -0500
                                      Re: Ping sbd: another programming challenge for your developmentally challenged children ronb <ronb02NOSPAM@gmail.com> - 2016-10-08 23:22 +0000
                                        Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-08 22:54 -0600
                                          Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-09 15:13 +0000
                                            Re: Ping sbd: another programming challenge for your developmentally challenged children Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-10-09 18:14 +0200
                                              Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-09 16:19 +0000
                                                Re: Ping sbd: another programming challenge for your developmentally challenged children Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-10-09 18:25 +0200
                                                  Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 07:21 -0500
                                                    Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-10 10:50 -0600
                                                  Re: Ping sbd: another programming challenge for your developmentally challenged children Snit <usenet@gallopinginsanity.com> - 2016-11-01 10:09 -0700
                                              Re: Ping sbd: another programming challenge for your developmentally challenged children William Poaster <wp@dev.null> - 2016-10-09 22:29 +0100
                                            Re: Ping sbd: another programming challenge for your developmentally challenged children Marek Novotny <marek.novotny@marspolar.com> - 2016-10-09 13:38 -0400
                                              Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-09 23:58 +0000
                                        Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 07:29 -0500
                                          Re: Ping sbd: another programming challenge for your developmentally challenged children William Poaster <wp@dev.null> - 2016-10-10 13:41 +0100
                                            Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 12:25 -0500
                                              Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-10 13:33 -0400
                                          Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-10 10:51 -0600
                                        Re: Ping sbd: another programming challenge for your developmentally challenged children chrisv <chrisv@nospam.invalid> - 2016-10-10 12:45 -0500
                                          Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-10 16:35 -0600
                                            Re: Ping sbd: another programming challenge for your developmentally challenged children Silver Slimer <.m@nsn.s> - 2016-10-10 18:54 -0400
                                              Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-10 21:56 -0600
                                          Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-10 22:48 +0000
                                            Re: Ping sbd: another programming challenge for your developmentally challenged children Jim Polaski <jpolaski@linuxmail.org> - 2016-10-11 00:02 +0000
                                              Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-10 21:58 -0600
                                            Re: Ping sbd: another programming challenge for your developmentally challenged children GreyCloud <Cumulus@mist.com> - 2016-10-10 21:58 -0600
                            Re: Ping sbd: another programming challenge for your developmentally challenged children Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-10-07 17:56 +0200
                              Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-07 13:25 -0400
                                Re: Ping sbd: another programming challenge for your developmentally challenged children Adlbifhr Mjduhgfks <am@random.us> - 2016-10-08 00:12 +0000
                                  Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-08 10:40 -0400
                                  Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-10 13:34 -0400
                      Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-07 04:15 +0000
                        Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 16:37 +0000
                          Re: Ping sbd: another programming challenge for your developmentally challenged children Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-10-07 20:34 +0200
            Re: Ping sbd: another programming challenge for your developmentally challenged children Steve Carroll <frelwizzen@gmail.com> - 2016-10-07 11:10 -0700
      Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-20 11:20 -0400
        Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-21 08:53 +0000
          Re: Ping sbd: another programming challenge for your developmentally challenged children Melzzzzz <mel@zzzzz.com> - 2016-10-21 13:19 +0200
          Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-21 10:45 -0400
            Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-22 01:06 +0000
              Re: Ping sbd: another programming challenge for your developmentally challenged children Melzzzzz <Melzzzzz@zzzzz.com> - 2016-10-22 02:15 +0000
                Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-22 02:40 +0000
                  Re: Ping sbd: another programming challenge for your developmentally challenged children Melzzzzz <mel@zzzzz.com> - 2016-10-22 05:00 +0200
                    Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-22 16:34 +0000
                      Re: Ping sbd: another programming challenge for your developmentally challenged children Melzzzzz <mel@zzzzz.com> - 2016-10-22 23:14 +0200
                        Re: Ping sbd: another programming challenge for your developmentally challenged children Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-10-22 18:24 -0400
                      Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-25 23:20 -0400
                        Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-26 05:22 +0000
                          Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-26 11:26 -0400
                            Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-26 20:42 +0000
                              Re: Ping sbd: another programming challenge for your developmentally challenged children Melzzzzz <mel@zzzzz.com> - 2016-10-27 01:45 +0200
                                Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-27 01:21 +0000
              Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-22 09:33 -0400
                Re: Ping sbd: another programming challenge for your developmentally challenged children deplorable owl <owl@rooftop.invalid> - 2016-10-22 16:50 +0000
    Re: Ping sbd: another programming challenge for your developmentally challenged children "Octavian W. Lagrange" <olagrang@perch.invalid> - 2016-10-06 21:25 +0000
    Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 16:30 +0000
      Re: Ping sbd: another programming challenge for your developmentally challenged children Steve Carroll <fretwizzer@gmail.com> - 2016-10-07 09:44 -0700
        Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 17:20 +0000
          Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-07 15:24 -0400
            Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 20:01 +0000
              Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-07 16:50 -0400
                Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 21:37 +0000
                  Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-07 17:54 -0400
                    Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 22:11 +0000
      Re: Ping sbd: another programming challenge for your developmentally challenged children DFS <nospam@dfs.com> - 2016-10-07 13:51 -0400
        Re: Ping sbd: another programming challenge for your developmentally challenged children Sandman <mr@sandman.net> - 2016-10-07 18:13 +0000
    Re: Ping sbd: another programming challenge for your developmentally challenged children Steve Carroll <frelwizzen@gmail.com> - 2016-10-07 11:10 -0700

Page 5 of 6 — ← Prev page 1 2 3 4 [5] 6  Next page →


#377149

FromDFS <nospam@dfs.com>
Date2016-10-21 10:45 -0400
Message-ID<nud9kv$434$1@dont-email.me>
In reply to#377114
On 10/21/2016 4:53 AM, deplorable owl wrote:

> python pwned by C.

I don't see any C.

[toc] | [prev] | [next] | [standalone]


#377239

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-10-22 01:06 +0000
Message-ID<hjagd803r.tji@rooftop.invalid>
In reply to#377149
DFS <nospam@dfs.com> wrote:
> On 10/21/2016 4:53 AM, deplorable owl wrote:
> 
>> python pwned by C.
> 
> I don't see any C.
> 

The code is at the bottom.

I made some changes so that it will now handle varying leading
quote marks and take its data from a file.  Also got rid of some 
function calls, so it's faster.

anon@lowtide:~/code/blah$ cat data
> Intel doesn't have to write a kernel from scratch. Nor does
Android.  They can use Linux. And if they need to make modifications for
their own benefit, that's fine, just share that back. They benefited by
not having to develop from scratch. But they need to give something back
in return.  Like the work they added. Both parties are give and take
something from each other. I'll take that over the BSD license any day
of the week.
anon@lowtide:~/code/blah$ 

anon@lowtide:~/code/blah$ cat data2
>> >> > Intel doesn't have to write a kernel from scratch. Nor does
Android.  They can use Linux. And if they need to make modifications for
their own benefit, that's fine, just share that back. They benefited by
not having to develop from scratch. But they need to give something back
in return.  Like the work they added. Both parties are give and take
something from each other. I'll take that over the BSD license any day
of the week.

anon@lowtide:~/code/blah$ 

anon@lowtide:~/code/blah$ ./nah data 15 40 1
15 > Intel doesn't have to write a kernel 
16 > from scratch. Nor does Android.  They 
17 > can use Linux. And if they need to 
18 > make modifications for their own 
19 > benefit, that's fine, just share that 
20 > back. They benefited by not having to 
21 > develop from scratch. But they need to 
22 > give something back in return.  Like 
23 > the work they added. Both parties are 
24 > give and take something from each 
25 > other. I'll take that over the BSD 
26 > license any day of the week. 

anon@lowtide:~/code/blah$ ./nah data2 15 40 1
15 >> >> > Intel doesn't have to write a 
16 >> >> > kernel from scratch. Nor does 
17 >> >> > Android.  They can use Linux. 
18 >> >> > And if they need to make 
19 >> >> > modifications for their own 
20 >> >> > benefit, that's fine, just share 
21 >> >> > that back. They benefited by not 
22 >> >> > having to develop from scratch. 
23 >> >> > But they need to give something 
24 >> >> > back in return.  Like the work 
25 >> >> > they added. Both parties are 
26 >> >> > give and take something from 
27 >> >> > each other. I'll take that over 
28 >> >> > the BSD license any day of the 
29 >> >> > week. 

anon@lowtide:~/code/blah$ 

Running Melzzzzz's haskell code on my system, the speeds are about the
same, with the C being slightly faster about 80 percent of the time,
but it's very close.

anon@lowtide:~/code/blah$ time ./split_line 15 40 1000 >out.txt

real    0m0.010s
user    0m0.008s
sys     0m0.000s
anon@lowtide:~/code/blah$ time ./nah data 15 40 1000 >out

real    0m0.007s
user    0m0.004s
sys     0m0.000s
anon@lowtide:~/code/blah$ time ./split_line 15 40 1000 >out.txt

real    0m0.008s
user    0m0.004s
sys     0m0.000s
anon@lowtide:~/code/blah$ time ./nah data 15 40 1000 >out

real    0m0.007s
user    0m0.004s
sys     0m0.000s
anon@lowtide:~/code/blah$ time ./split_line 15 40 1000 >out.txt

real    0m0.008s
user    0m0.004s
sys     0m0.000s
anon@lowtide:~/code/blah$ time ./nah data 15 40 1000 >out

real    0m0.006s
user    0m0.004s
sys     0m0.000s
anon@lowtide:~/code/blah$ 


-------------------------- begin code --------------------------------
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

void split(char *,char *,int, int, char *, int);

int main(int argc, char *argv[])
{
   int i=0;
   int c=0;
   long filesize=0;
   char *txt;
   char *str;
   char *txtsave;
   char *quotes;
   int quotecount=0;
   char *s;
   char *save;

   if(argc!=5)
   {
     fprintf(stderr,"argc!=4\n");
     exit(1);
   }

   FILE *fp=fopen(argv[1],"r");
   if(fp==NULL)
   {
      fprintf(stderr,"fopen\n");
      exit(1);
   }

   fseek(fp,0,SEEK_END);
   filesize=ftell(fp);
   fseek(fp,0,SEEK_SET);

   txt=malloc(filesize+1);
   if(txt==NULL)
   {
     fprintf(stderr,"txt malloc\n");
     exit(1);
   } 

   str=malloc(filesize+1);
   if(str==NULL)
   {
     fprintf(stderr,"str malloc\n");
     exit(1);
   } 
   txtsave=txt;

   while((c=fgetc(fp))!=EOF)
   {
     if(c=='\n')
     {
        *txt++=' '; 
     }
     else
     {
        *txt++=c;
     }
   }
   txt=txtsave;   

   s=txt;
   save=s;

   while(*s=='>'||*s==' ')
   {
    s++;
    quotecount++; 
   }

   quotes=malloc(quotecount+1);
   if(quotes==NULL)
   {
     fprintf(stderr,"quotes malloc\n");
     exit(1);
   }

   char *quotessave=quotes;
   s=save;


   while(*s=='>'||*s==' ')
   {
    *quotes++=*s++; 
   }

   s=save;
   quotes=quotessave;


   for(i=0;i<atoi(argv[4]);i++)
   {
     split(str,txt,atoi(argv[2]),atoi(argv[3]),quotes,quotecount);
   }

   free(quotes);
   free(txt);
   fclose(fp);
   return 0;
}

void split(char *str,char *t,int n,int m, char *quotes, int quotecount)
{
   char *s=t;
   char *ssave=str;
   int i=0;
   int sc=0;

   while(*s=='>'||*s==' ')
   {
    s++;
   }

   while(*t=='>'||*t==' ')
   {
    t++;
   }

   while(*t++!='\0')
   {
      if(*t==' ')
      {
        sc++;
      }
      if(i++==m-quotecount)
      {
        if(sc>0)
        {
           while(*t!=' ') 
           {
               t--;
           }
        }
        while(t<s)
        {
          t++;
        }
        while(s<=t&&*s!='\0') 
        {
           *str++=*s++;
        } 
        *str='\0';
        str=ssave;
        printf("%d %s%s\n",n++,quotes,str);
        i=0;
      }
   }

   printf("%d %s%s\n\n",n++,quotes,s);
}

-------------------------- end code --------------------------------

[toc] | [prev] | [next] | [standalone]


#377250

FromMelzzzzz <Melzzzzz@zzzzz.com>
Date2016-10-22 02:15 +0000
Message-ID<nuei3o$ghc$1@news.albasani.net>
In reply to#377239
On 2016-10-22, deplorable owl <owl@rooftop.invalid> wrote:
> DFS <nospam@dfs.com> wrote:
>> On 10/21/2016 4:53 AM, deplorable owl wrote:
>> 
>>> python pwned by C.
>> 
>> I don't see any C.
>> 
>
> The code is at the bottom.
>
> I made some changes so that it will now handle varying leading
> quote marks and take its data from a file.  Also got rid of some 
> function calls, so it's faster.
>
> anon@lowtide:~/code/blah$ cat data
>> Intel doesn't have to write a kernel from scratch. Nor does
> Android.  They can use Linux. And if they need to make modifications for
> their own benefit, that's fine, just share that back. They benefited by
> not having to develop from scratch. But they need to give something back
> in return.  Like the work they added. Both parties are give and take
> something from each other. I'll take that over the BSD license any day
> of the week.
> anon@lowtide:~/code/blah$ 
>
> anon@lowtide:~/code/blah$ cat data2
>>> >> > Intel doesn't have to write a kernel from scratch. Nor does
> Android.  They can use Linux. And if they need to make modifications for
> their own benefit, that's fine, just share that back. They benefited by
> not having to develop from scratch. But they need to give something back
> in return.  Like the work they added. Both parties are give and take
> something from each other. I'll take that over the BSD license any day
> of the week.
>
> anon@lowtide:~/code/blah$ 
>
> anon@lowtide:~/code/blah$ ./nah data 15 40 1
> 15 > Intel doesn't have to write a kernel 
> 16 > from scratch. Nor does Android.  They 
> 17 > can use Linux. And if they need to 
> 18 > make modifications for their own 
> 19 > benefit, that's fine, just share that 
> 20 > back. They benefited by not having to 
> 21 > develop from scratch. But they need to 
> 22 > give something back in return.  Like 
> 23 > the work they added. Both parties are 
> 24 > give and take something from each 
> 25 > other. I'll take that over the BSD 
> 26 > license any day of the week. 
>
> anon@lowtide:~/code/blah$ ./nah data2 15 40 1
> 15 >> >> > Intel doesn't have to write a 
> 16 >> >> > kernel from scratch. Nor does 
> 17 >> >> > Android.  They can use Linux. 
> 18 >> >> > And if they need to make 
> 19 >> >> > modifications for their own 
> 20 >> >> > benefit, that's fine, just share 
> 21 >> >> > that back. They benefited by not 
> 22 >> >> > having to develop from scratch. 
> 23 >> >> > But they need to give something 
> 24 >> >> > back in return.  Like the work 
> 25 >> >> > they added. Both parties are 
> 26 >> >> > give and take something from 
> 27 >> >> > each other. I'll take that over 
> 28 >> >> > the BSD license any day of the 
> 29 >> >> > week. 
>
> anon@lowtide:~/code/blah$ 
>
> Running Melzzzzz's haskell code on my system, the speeds are about the
> same, with the C being slightly faster about 80 percent of the time,
> but it's very close.
>
> anon@lowtide:~/code/blah$ time ./split_line 15 40 1000 >out.txt
>
> real    0m0.010s
> user    0m0.008s
> sys     0m0.000s
> anon@lowtide:~/code/blah$ time ./nah data 15 40 1000 >out
>
> real    0m0.007s
> user    0m0.004s
> sys     0m0.000s
> anon@lowtide:~/code/blah$ time ./split_line 15 40 1000 >out.txt
>
> real    0m0.008s
> user    0m0.004s
> sys     0m0.000s
> anon@lowtide:~/code/blah$ time ./nah data 15 40 1000 >out
>
> real    0m0.007s
> user    0m0.004s
> sys     0m0.000s
> anon@lowtide:~/code/blah$ time ./split_line 15 40 1000 >out.txt
>
> real    0m0.008s
> user    0m0.004s
> sys     0m0.000s
> anon@lowtide:~/code/blah$ time ./nah data 15 40 1000 >out
>
> real    0m0.006s
> user    0m0.004s
> sys     0m0.000s
> anon@lowtide:~/code/blah$ 
>
>
> -------------------------- begin code --------------------------------
> #include <stdio.h>
> #include <string.h>
> #include <stdlib.h>
> #include <ctype.h>
>
> void split(char *,char *,int, int, char *, int);
>
> int main(int argc, char *argv[])
> {
>    int i=0;
>    int c=0;
>    long filesize=0;
>    char *txt;
>    char *str;
>    char *txtsave;
>    char *quotes;
>    int quotecount=0;
>    char *s;
>    char *save;
>
>    if(argc!=5)
>    {
>      fprintf(stderr,"argc!=4\n");
>      exit(1);
>    }
>
>    FILE *fp=fopen(argv[1],"r");
>    if(fp==NULL)
>    {
>       fprintf(stderr,"fopen\n");
>       exit(1);
>    }
>
>    fseek(fp,0,SEEK_END);
>    filesize=ftell(fp);
>    fseek(fp,0,SEEK_SET);
>
>    txt=malloc(filesize+1);
>    if(txt==NULL)
>    {
>      fprintf(stderr,"txt malloc\n");
>      exit(1);
>    } 
>
>    str=malloc(filesize+1);
>    if(str==NULL)
>    {
>      fprintf(stderr,"str malloc\n");
>      exit(1);
>    } 
>    txtsave=txt;
>
>    while((c=fgetc(fp))!=EOF)
>    {
>      if(c=='\n')
>      {
>         *txt++=' '; 
>      }
>      else
>      {
>         *txt++=c;
>      }
>    }
>    txt=txtsave;   
>
>    s=txt;
>    save=s;
>
>    while(*s=='>'||*s==' ')
>    {
>     s++;
>     quotecount++; 
>    }
>
>    quotes=malloc(quotecount+1);
>    if(quotes==NULL)
>    {
>      fprintf(stderr,"quotes malloc\n");
>      exit(1);
>    }
>
>    char *quotessave=quotes;
>    s=save;
>
>
>    while(*s=='>'||*s==' ')
>    {
>     *quotes++=*s++; 
>    }
>
>    s=save;
>    quotes=quotessave;
>
>
>    for(i=0;i<atoi(argv[4]);i++)
>    {
>      split(str,txt,atoi(argv[2]),atoi(argv[3]),quotes,quotecount);
>    }
>
>    free(quotes);
>    free(txt);
>    fclose(fp);
>    return 0;
> }
>
> void split(char *str,char *t,int n,int m, char *quotes, int quotecount)
> {
>    char *s=t;
>    char *ssave=str;
>    int i=0;
>    int sc=0;
>
>    while(*s=='>'||*s==' ')
>    {
>     s++;
>    }
>
>    while(*t=='>'||*t==' ')
>    {
>     t++;
>    }
>
>    while(*t++!='\0')
>    {
>       if(*t==' ')
>       {
>         sc++;
>       }
>       if(i++==m-quotecount)
>       {
>         if(sc>0)
>         {
>            while(*t!=' ') 
>            {
>                t--;
>            }
>         }
>         while(t<s)
>         {
>           t++;
>         }
>         while(s<=t&&*s!='\0') 
>         {
>            *str++=*s++;
>         } 
>         *str='\0';
>         str=ssave;
>         printf("%d %s%s\n",n++,quotes,str);
>         i=0;
>       }
>    }
>
>    printf("%d %s%s\n\n",n++,quotes,s);
> }
>
> -------------------------- end code --------------------------------

[bmaxa@maxa-pc haskell]$ time ./split_line 15 40 1000 data.txt > out.txt

real	0m0.029s
user	0m0.023s
sys	0m0.003s
[bmaxa@maxa-pc haskell]$ head -n 20 out.txt
15 >> >> > Intel doesn't have to write a kernel
16 >> >> > from scratch. Nor does Android. They
17 >> >> > can use Linux. And if they need to make
18 >> >> > modifications for their own benefit,
19 >> >> > that's fine, just share that back. They
20 >> >> > benefited by not having to develop from
21 >> >> > scratch. But they need to give
22 >> >> > something back in return. Like the work
23 >> >> > they added. Both parties are give and
24 >> >> > take something from each other. I'll
25 >> >> > take that over the BSD license any day
26 >> >> > of the week.

15 >> >> > Intel doesn't have to write a kernel
16 >> >> > from scratch. Nor does Android. They
17 >> >> > can use Linux. And if they need to make
18 >> >> > modifications for their own benefit,
19 >> >> > that's fine, just share that back. They
20 >> >> > benefited by not having to develop from
21 >> >> > scratch. But they need to give

[bmaxa@maxa-pc haskell]$ cat split_line.hs
import System.Environment
import Control.Monad

predicate x = x == '>' || x == ' '

reformat xs enum len = reformat' (takeWhile predicate xs)
                                 (words $ dropWhile predicate xs) [] [] enum 0
 where reformat' quot [] line lines i llen = 
                                 unlines (lines ++ form i quot line)
       reformat' quot (x:xs) line lines i llen = if length x + llen < len
                                 then reformat' quot xs (x:line) 
                                                   lines i 
                                                   (llen + length x + 1)
                                 else reformat' 
                                      quot (x:xs) [] 
                                      (lines++form i quot line)
                                      (i+1)
                                      0
       form i quot line = [show i ++ " " ++ quot ++ unwords (reverse line)]
main = do
    args <- getArgs
    let parse (enum:len:count:[]) = return
            (read enum, read len,read count,txt)
        parse (enum:len:count:file:[]) = do
            txt <- readFile file
            return (read enum,read len,read count,txt)
    (enum,len,count,txt) <- parse args
    replicateM count (putStrLn $ reformat txt enum len)
    
txt = ">Intel doesn't have to write a kernel from scratch. Nor does\
\ Android.  They can use Linux. And if they need to make modifications for\
\ their own benefit, that's fine, just share that back. They benefited by\
\ not having to develop from scratch. But they need to give something back\
\ in return.  Like the work they added. Both parties are give and take\
\ something from each other. I'll take that over the BSD license any day\
\ of the week."

-- 
press any key to continue or any other to quit

[toc] | [prev] | [next] | [standalone]


#377252

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-10-22 02:40 +0000
Message-ID<ahjdgjic90.2tg4@rooftop.invalid>
In reply to#377250
Melzzzzz <Melzzzzz@zzzzz.com> wrote:
> On 2016-10-22, deplorable owl <owl@rooftop.invalid> wrote:
>> }
>>
>> -------------------------- end code --------------------------------
> 
> [bmaxa@maxa-pc haskell]$ time ./split_line 15 40 1000 data.txt > out.txt
> 
> real    0m0.029s
> user    0m0.023s
> sys     0m0.003s
> [bmaxa@maxa-pc haskell]$ head -n 20 out.txt
> 15 >> >> > Intel doesn't have to write a kernel
> 16 >> >> > from scratch. Nor does Android. They
> 17 >> >> > can use Linux. And if they need to make
> 18 >> >> > modifications for their own benefit,
> 19 >> >> > that's fine, just share that back. They
> 20 >> >> > benefited by not having to develop from
> 21 >> >> > scratch. But they need to give
> 22 >> >> > something back in return. Like the work
> 23 >> >> > they added. Both parties are give and
> 24 >> >> > take something from each other. I'll
> 25 >> >> > take that over the BSD license any day
> 26 >> >> > of the week.
> 
> 15 >> >> > Intel doesn't have to write a kernel
> 16 >> >> > from scratch. Nor does Android. They
> 17 >> >> > can use Linux. And if they need to make
> 18 >> >> > modifications for their own benefit,
> 19 >> >> > that's fine, just share that back. They
> 20 >> >> > benefited by not having to develop from
> 21 >> >> > scratch. But they need to give
> 
> [bmaxa@maxa-pc haskell]$ cat split_line.hs
> import System.Environment
> import Control.Monad
> 
> predicate x = x == '>' || x == ' '
> 
> reformat xs enum len = reformat' (takeWhile predicate xs)
>                                  (words $ dropWhile predicate xs) [] [] enum 0
>  where reformat' quot [] line lines i llen = 
>                                  unlines (lines ++ form i quot line)
>        reformat' quot (x:xs) line lines i llen = if length x + llen < len
>                                  then reformat' quot xs (x:line) 
>                                                    lines i 
>                                                    (llen + length x + 1)
>                                  else reformat' 
>                                       quot (x:xs) [] 
>                                       (lines++form i quot line)
>                                       (i+1)
>                                       0
>        form i quot line = [show i ++ " " ++ quot ++ unwords (reverse line)]
> main = do
>     args <- getArgs
>     let parse (enum:len:count:[]) = return
>             (read enum, read len,read count,txt)
>         parse (enum:len:count:file:[]) = do
>             txt <- readFile file
>             return (read enum,read len,read count,txt)
>     (enum,len,count,txt) <- parse args
>     replicateM count (putStrLn $ reformat txt enum len)
>     
> txt = ">Intel doesn't have to write a kernel from scratch. Nor does\
> \ Android.  They can use Linux. And if they need to make modifications for\
> \ their own benefit, that's fine, just share that back. They benefited by\
> \ not having to develop from scratch. But they need to give something back\
> \ in return.  Like the work they added. Both parties are give and take\
> \ something from each other. I'll take that over the BSD license any day\
> \ of the week."
> 

About the same.

anon@lowtide:~/code/blah$ diff data2 data.txt
anon@lowtide:~/code/blah$ time ./split_line2 15 40 1000 data.txt > out.txt

real    0m0.008s
user    0m0.004s
sys     0m0.000s
anon@lowtide:~/code/blah$ time ./nah data2 15 40 1000 >out

real    0m0.008s
user    0m0.004s
sys     0m0.000s
anon@lowtide:~/code/blah$ time ./split_line2 15 40 1000 data.txt > out.txt

real    0m0.007s
user    0m0.004s
sys     0m0.000s
anon@lowtide:~/code/blah$ time ./nah data2 15 40 1000 >out

real    0m0.007s
user    0m0.004s
sys     0m0.000s
anon@lowtide:~/code/blah$ time ./split_line2 15 40 1000 data.txt > out.txt

real    0m0.015s
user    0m0.008s
sys     0m0.004s
anon@lowtide:~/code/blah$ time ./nah data2 15 40 1000 >out

real    0m0.008s
user    0m0.004s
sys     0m0.000s
anon@lowtide:~/code/blah$ time ./split_line2 15 40 1000 data.txt > out.txt

real    0m0.017s
user    0m0.020s
sys     0m0.000s
anon@lowtide:~/code/blah$ time ./nah data2 15 40 1000 >out

real    0m0.013s
user    0m0.008s
sys     0m0.004s
anon@lowtide:~/code/blah$ 
anon@lowtide:~/code/blah$ head -n 20 out.txt
15 >> >> > Intel doesn't have to write a kernel
16 >> >> > from scratch. Nor does Android. They
17 >> >> > can use Linux. And if they need to make
18 >> >> > modifications for their own benefit,
19 >> >> > that's fine, just share that back. They
20 >> >> > benefited by not having to develop from
21 >> >> > scratch. But they need to give
22 >> >> > something back in return. Like the work
23 >> >> > they added. Both parties are give and
24 >> >> > take something from each other. I'll
25 >> >> > take that over the BSD license any day
26 >> >> > of the week.

15 >> >> > Intel doesn't have to write a kernel
16 >> >> > from scratch. Nor does Android. They
17 >> >> > can use Linux. And if they need to make
18 >> >> > modifications for their own benefit,
19 >> >> > that's fine, just share that back. They
20 >> >> > benefited by not having to develop from
21 >> >> > scratch. But they need to give
anon@lowtide:~/code/blah$

anon@lowtide:~/code/blah$ head -n 20 out
15 >> >> > Intel doesn't have to write a 
16 >> >> > kernel from scratch. Nor does 
17 >> >> > Android.  They can use Linux. 
18 >> >> > And if they need to make 
19 >> >> > modifications for their own 
20 >> >> > benefit, that's fine, just share 
21 >> >> > that back. They benefited by not 
22 >> >> > having to develop from scratch. 
23 >> >> > But they need to give something 
24 >> >> > back in return.  Like the work 
25 >> >> > they added. Both parties are 
26 >> >> > give and take something from 
27 >> >> > each other. I'll take that over 
28 >> >> > the BSD license any day of the 
29 >> >> > week. 

15 >> >> > Intel doesn't have to write a 
16 >> >> > kernel from scratch. Nor does 
17 >> >> > Android.  They can use Linux. 
18 >> >> > And if they need to make 
anon@lowtide:~/code/blah$

I'm counting the quote markers as part of the width limit.

[toc] | [prev] | [next] | [standalone]


#377255

FromMelzzzzz <mel@zzzzz.com>
Date2016-10-22 05:00 +0200
Message-ID<20161022050041.447023af@maxa-pc.cpe.bvcom.net>
In reply to#377252
On Sat, 22 Oct 2016 02:40:29 +0000 (UTC)
deplorable owl <owl@rooftop.invalid> wrote:

> 
> I'm counting the quote markers as part of the width limit.
> 

It's trivial to add.

[bmaxa@maxa-pc haskell]$ time ./split_line 15 40 1000 data.txt > out.txt

real	0m0.033s
user	0m0.030s
sys	0m0.000s
[bmaxa@maxa-pc haskell]$ head -n 20 out.txt
15 >> >> > Intel doesn't have to write a
16 >> >> > kernel from scratch. Nor does
17 >> >> > Android. They can use Linux.
18 >> >> > And if they need to make
19 >> >> > modifications for their own
20 >> >> > benefit, that's fine, just
21 >> >> > share that back. They
22 >> >> > benefited by not having to
23 >> >> > develop from scratch. But they
24 >> >> > need to give something back in
25 >> >> > return. Like the work they
26 >> >> > added. Both parties are give
27 >> >> > and take something from each
28 >> >> > other. I'll take that over the
29 >> >> > BSD license any day of the
30 >> >> > week.

15 >> >> > Intel doesn't have to write a
16 >> >> > kernel from scratch. Nor does
17 >> >> > Android. They can use Linux.
[bmaxa@maxa-pc haskell]$ cat split_line.hs
import System.Environment
import Control.Monad

predicate x = x == '>' || x == ' '

reformat xs enum len = reformat' (takeWhile predicate xs)
                                 (words $ dropWhile predicate xs) [] [] enum 0
 where reformat' quot [] line lines i llen = 
                                 unlines (lines ++ form i quot line)
       reformat' quot (x:xs) line lines i llen = 
                                 if length x + llen + length quot + 1 < len
                                 then reformat' quot xs (x:line) 
                                                   lines i 
                                                   (llen + length x + 1)
                                 else reformat' 
                                      quot (x:xs) [] 
                                      (lines++form i quot line)
                                      (i+1)
                                      0
       form i quot line = [show i ++ " " ++ quot ++ unwords (reverse line)]
main = do
    args <- getArgs
    let parse (enum:len:count:[]) = return
            (read enum, read len,read count,txt)
        parse (enum:len:count:file:[]) = do
            txt <- readFile file
            return (read enum,read len,read count,txt)
    (enum,len,count,txt) <- parse args
    replicateM count (putStrLn $ reformat txt enum len)
    
txt = ">Intel doesn't have to write a kernel from scratch. Nor does\
\ Android.  They can use Linux. And if they need to make modifications for\
\ their own benefit, that's fine, just share that back. They benefited by\
\ not having to develop from scratch. But they need to give something back\
\ in return.  Like the work they added. Both parties are give and take\
\ something from each other. I'll take that over the BSD license any day\
\ of the week."


-- 
press any key to continue or any other to quit

[toc] | [prev] | [next] | [standalone]


#377304

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-10-22 16:34 +0000
Message-ID<ahjgdvod03a.ag@rooftop.invalid>
In reply to#377255
Melzzzzz <mel@zzzzz.com> wrote:
> On Sat, 22 Oct 2016 02:40:29 +0000 (UTC)
> deplorable owl <owl@rooftop.invalid> wrote:
> 
>> 
>> I'm counting the quote markers as part of the width limit.
>> 
> 
> It's trivial to add.
> 

No doubt.  Just noting the output differences.


> [bmaxa@maxa-pc haskell]$ time ./split_line 15 40 1000 data.txt > out.txt
> 
> real    0m0.033s
> user    0m0.030s
> sys     0m0.000s
> [bmaxa@maxa-pc haskell]$ head -n 20 out.txt
> 15 >> >> > Intel doesn't have to write a
> 16 >> >> > kernel from scratch. Nor does
> 17 >> >> > Android. They can use Linux.
> 18 >> >> > And if they need to make
> 19 >> >> > modifications for their own
> 20 >> >> > benefit, that's fine, just
> 21 >> >> > share that back. They
> 22 >> >> > benefited by not having to
> 23 >> >> > develop from scratch. But they
> 24 >> >> > need to give something back in
> 25 >> >> > return. Like the work they
> 26 >> >> > added. Both parties are give
> 27 >> >> > and take something from each
> 28 >> >> > other. I'll take that over the
> 29 >> >> > BSD license any day of the
> 30 >> >> > week.
> 
> 15 >> >> > Intel doesn't have to write a
> 16 >> >> > kernel from scratch. Nor does
> 17 >> >> > Android. They can use Linux.
> [bmaxa@maxa-pc haskell]$ cat split_line.hs
> import System.Environment
> import Control.Monad
> 
> predicate x = x == '>' || x == ' '
> 
> reformat xs enum len = reformat' (takeWhile predicate xs)
>                                  (words $ dropWhile predicate xs) [] [] enum 0
>  where reformat' quot [] line lines i llen = 
>                                  unlines (lines ++ form i quot line)
>        reformat' quot (x:xs) line lines i llen = 
>                                  if length x + llen + length quot + 1 < len
>                                  then reformat' quot xs (x:line) 
>                                                    lines i 
>                                                    (llen + length x + 1)
>                                  else reformat' 
>                                       quot (x:xs) [] 
>                                       (lines++form i quot line)
>                                       (i+1)
>                                       0
>        form i quot line = [show i ++ " " ++ quot ++ unwords (reverse line)]
> main = do
>     args <- getArgs
>     let parse (enum:len:count:[]) = return
>             (read enum, read len,read count,txt)
>         parse (enum:len:count:file:[]) = do
>             txt <- readFile file
>             return (read enum,read len,read count,txt)
>     (enum,len,count,txt) <- parse args
>     replicateM count (putStrLn $ reformat txt enum len)
>     
> txt = ">Intel doesn't have to write a kernel from scratch. Nor does\
> \ Android.  They can use Linux. And if they need to make modifications for\
> \ their own benefit, that's fine, just share that back. They benefited by\
> \ not having to develop from scratch. But they need to give something back\
> \ in return.  Like the work they added. Both parties are give and take\
> \ something from each other. I'll take that over the BSD license any day\
> \ of the week."
> 
> 

That language would take some getting used to.
I don't like forced indentation.  That's why I don't like python.


[toc] | [prev] | [next] | [standalone]


#377326

FromMelzzzzz <mel@zzzzz.com>
Date2016-10-22 23:14 +0200
Message-ID<20161022231412.1fb54c72@maxa-pc.cpe.bvcom.net>
In reply to#377304
On Sat, 22 Oct 2016 16:34:03 +0000 (UTC)
deplorable owl <owl@rooftop.invalid> wrote:


> 
> That language would take some getting used to.
> I don't like forced indentation.  That's why I don't like python.
> 
> 
> 
Ih Haskell you can have both ways. Curly braces and semicolons and
indentations. It's that no one uses braces or never I have seen...


-- 
press any key to continue or any other to quit

[toc] | [prev] | [next] | [standalone]


#377334

FromChris Ahlstrom <OFeem1987@teleworm.us>
Date2016-10-22 18:24 -0400
Message-ID<nugp6f$n16$2@dont-email.me>
In reply to#377326
Melzzzzz wrote this copyrighted missive and expects royalties:

> On Sat, 22 Oct 2016 16:34:03 +0000 (UTC)
> deplorable owl <owl@rooftop.invalid> wrote:
>
>> That language would take some getting used to.
>> I don't like forced indentation.  That's why I don't like python.

I actually agree with "bowel" on that one.

> Ih Haskell you can have both ways. Curly braces and semicolons and
> indentations. It's that no one uses braces or never I have seen...

I'd thought syntax-by-white-space had gone out with FORTRAN in the early
70's.  Guido's justification for it is quite specious.

-- 
If one cannot enjoy reading a book over and over again, there is no use
in reading it at all.
		-- Oscar Wilde

[toc] | [prev] | [next] | [standalone]


#378061

FromDFS <nospam@dfs.com>
Date2016-10-25 23:20 -0400
Message-ID<nup7ef$siq$3@dont-email.me>
In reply to#377304
On 10/22/2016 12:34 PM, deplorable owl wrote:

> I don't like forced indentation.  That's why I don't like python.


The .py is always right!

Consistent indentation improves readability, and as you know code is
much more often read than written.


Is it actually the forced indenting that bothers you, or the amt of
whitespace?

You can reduce the whitespace somewhat by writing 2-statement
lines where reasonable.

for i in range(len(d)): p.append(d[i][1])


And you can probably change your editor's default tab indentation to 2
or 3 spaces, if the standard 4 looks like too much whitespace.

[toc] | [prev] | [next] | [standalone]


#378081

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-10-26 05:22 +0000
Message-ID<ahjdgoe9.faf@rooftop.invalid>
In reply to#378061
DFS <nospam@dfs.com> wrote:
> On 10/22/2016 12:34 PM, deplorable owl wrote:
> 
>> I don't like forced indentation.  That's why I don't like python.
> 
> 
> The .py is always right!
> 
> Consistent indentation improves readability, and as you know code is
> much more often read than written.
> 
> 
> Is it actually the forced indenting that bothers you, or the amt of
> whitespace?
> 

No, it's the forced indentation.  I indent my own code most of the time
unless it's really short, but even then while debugging I'll often
drop in test code left-flushed so that it stands out from the rest.
I don't need some nanny making me pretty up my code a certain way.
Why does the freaking source need to have a "look" to it?  If it looks
bad, reformat before you start to read it.


> You can reduce the whitespace somewhat by writing 2-statement
> lines where reasonable.
> 
> for i in range(len(d)): p.append(d[i][1])
> 
> 
> And you can probably change your editor's default tab indentation to 2
> or 3 spaces, if the standard 4 looks like too much whitespace.
> 

Also, python loops are just retarded.
What the hell is wrong with a simple indexed for loop that python
makes you go through this contrived mess:

i=0
while i < whatever
  something 
  i+1

or else with some bullshit with range() or enumerate().

I understand python a widely loved and used language.  I just
don't like it.

[toc] | [prev] | [next] | [standalone]


#378136

FromDFS <nospam@dfs.com>
Date2016-10-26 11:26 -0400
Message-ID<nuqhu5$rrk$1@dont-email.me>
In reply to#378081
On 10/26/2016 1:22 AM, deplorable owl wrote:
> DFS <nospam@dfs.com> wrote:
>> On 10/22/2016 12:34 PM, deplorable owl wrote:
>>
>>> I don't like forced indentation.  That's why I don't like python.
>>
>>
>> The .py is always right!
>>
>> Consistent indentation improves readability, and as you know code is
>> much more often read than written.
>>
>>
>> Is it actually the forced indenting that bothers you, or the amt of
>> whitespace?
>>
> 
> No, it's the forced indentation.  I indent my own code most of the time

But python forces it, and you're a proud programmer who won't EVER be
told what to do!


> unless it's really short, but even then while debugging I'll often
> drop in test code left-flushed so that it stands out from the rest.
> I don't need some nanny making me pretty up my code a certain way.
> Why does the freaking source need to have a "look" to it?  If it looks
> bad, reformat before you start to read it.

Appearance isn't why indentation is required.  You can indent 1 space if
you want.



>> You can reduce the whitespace somewhat by writing 2-statement
>> lines where reasonable.
>>
>> for i in range(len(d)): p.append(d[i][1])
>>
>>
>> And you can probably change your editor's default tab indentation to 2
>> or 3 spaces, if the standard 4 looks like too much whitespace.
>>
> 
> Also, python loops are just retarded.
> What the hell is wrong with a simple indexed for loop that python
> makes you go through this contrived mess:
> 
> i=0
> while i < whatever
>   something 
>   i+1
> 
> or else with some bullshit with range() or enumerate().


What's wrong with 'for i in range(0,101,10)'?



> I understand python a widely loved and used language.  I just
> don't like it.

It's great in many ways.

In what other language/system can you produce a decent set of newsgroup
stats in just 22 lines?
-------------------------------------------------------
import sys as y,nntplib as t
s='news.eternal-september.org'
g='comp.os.linux.advocacy'
n=t.NNTP(s,119,'<usr>','<pwd>')
r,a,b,e,gn=n.group(g)
def printStat(st,hd,rg):
	r,d=n.xhdr(st,'%s-%s'%rg)
	p=[]
	for i in range(len(d)):
		v=d[i][1]
		if st=='Subject':v=v[4:] if v[:3]=='Re:' else v
		p.append(v)
	x=[(i,p.count(i)) for i in set(p)]
	x.sort(key=lambda s:(-s[1],s[0].lower()))
	print('Posts  %s %s'%(len(set(p)),hd))
	for v in x: print(' %s     %s'%(v[1],v[0]))
	print
m=(int(e)-int(y.argv[2])+1,int(e))
printStat("From","Posters",m)
printStat("Subject","Subjects",m)
printStat("User-Agent","User-Agents",m)
n.quit()
-------------------------------------------------------
usage: python filename.py last N


Those huge 8-space indents are added by Thunderbird.  In my code
editor, the tab is just 2 spaces.



or scrape a web page and print + save it to .csv in 19 lines
----------------------------------------------------------------------
from lxml import html
import requests
enthought = "https://www.enthought.com/products/canopy/package-index/"
page = requests.get(enthought)
tree = html.fromstring(page.content)
p1 = tree.xpath('//a[@target="_blank"]/text()')
p2 = tree.xpath('//td[@valign="middle"]/text()')
for i in range(4): p1.pop(0)
p2 = [t.replace("\r\n", "")  for t in p2]
p2 = filter(None, (t.strip() for t in p2))
p = []	
for i in xrange(0,len(p1),2):
	p.insert(i,(p1[i],p2[i],p1[i+1],p2[i+1]))
csvfile = "EnThought_Packages_min.csv"
with open(csvfile, "w") as f:
	f.write("PackageName,Version,License,Description\n")
	for p,v,l,d in p:
		print "%s, %s, %s, %s" % (p,v,l,d)
		f.write("%s,%s,%s,%s\n" % (p,v,l.replace(",",""),d.replace(",","")))
-------------------------------------------------------
usage python filename.py


The HTML on that webpage is changed, so this scrape example
doesn't work correctly like it used to.  It runs, but the output is fubar.





[toc] | [prev] | [next] | [standalone]


#378170

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-10-26 20:42 +0000
Message-ID<ahjdlbie.ag@rooftop.invalid>
In reply to#378136
DFS <nospam@dfs.com> wrote:
> On 10/26/2016 1:22 AM, deplorable owl wrote:
>> DFS <nospam@dfs.com> wrote:
>>> On 10/22/2016 12:34 PM, deplorable owl wrote:
>>>
>>>> I don't like forced indentation.  That's why I don't like python.
>>>
>>>
>>> The .py is always right!
>>>
>>> Consistent indentation improves readability, and as you know code is
>>> much more often read than written.
>>>
>>>
>>> Is it actually the forced indenting that bothers you, or the amt of
>>> whitespace?
>>>
>> 
>> No, it's the forced indentation.  I indent my own code most of the time
> 
> But python forces it, and you're a proud programmer who won't EVER be
> told what to do!
> 
> 
>> unless it's really short, but even then while debugging I'll often
>> drop in test code left-flushed so that it stands out from the rest.
>> I don't need some nanny making me pretty up my code a certain way.
>> Why does the freaking source need to have a "look" to it?  If it looks
>> bad, reformat before you start to read it.
> 
> Appearance isn't why indentation is required.  You can indent 1 space if
> you want.
> 

One space or a hundred, it's still all about appearance.


> 
> 
>>> You can reduce the whitespace somewhat by writing 2-statement
>>> lines where reasonable.
>>>
>>> for i in range(len(d)): p.append(d[i][1])
>>>
>>>
>>> And you can probably change your editor's default tab indentation to 2
>>> or 3 spaces, if the standard 4 looks like too much whitespace.
>>>
>> 
>> Also, python loops are just retarded.
>> What the hell is wrong with a simple indexed for loop that python
>> makes you go through this contrived mess:
>> 
>> i=0
>> while i < whatever
>>   something 
>>   i+1
>> 
>> or else with some bullshit with range() or enumerate().
> 
> 
> What's wrong with 'for i in range(0,101,10)'?
> 
> 

Do this without jumping through hoops:
for (i=0; i<count && blah[i]>i ;i++)

[toc] | [prev] | [next] | [standalone]


#378190

FromMelzzzzz <mel@zzzzz.com>
Date2016-10-27 01:45 +0200
Message-ID<20161027014543.7ec70bfd@maxa-pc.cpe.bvcom.net>
In reply to#378170
On Wed, 26 Oct 2016 20:42:28 +0000 (UTC)
deplorable owl <owl@rooftop.invalid> wrote:

> DFS <nospam@dfs.com> wrote:
> > On 10/26/2016 1:22 AM, deplorable owl wrote:  
> >> DFS <nospam@dfs.com> wrote:  
> >>> On 10/22/2016 12:34 PM, deplorable owl wrote:
> >>>  
> >>>> I don't like forced indentation.  That's why I don't like
> >>>> python.  
> >>>
> >>>
> >>> The .py is always right!
> >>>
> >>> Consistent indentation improves readability, and as you know code
> >>> is much more often read than written.
> >>>
> >>>
> >>> Is it actually the forced indenting that bothers you, or the amt
> >>> of whitespace?
> >>>  
> >> 
> >> No, it's the forced indentation.  I indent my own code most of the
> >> time  
> > 
> > But python forces it, and you're a proud programmer who won't EVER
> > be told what to do!
> > 
> >   
> >> unless it's really short, but even then while debugging I'll often
> >> drop in test code left-flushed so that it stands out from the rest.
> >> I don't need some nanny making me pretty up my code a certain way.
> >> Why does the freaking source need to have a "look" to it?  If it
> >> looks bad, reformat before you start to read it.  
> > 
> > Appearance isn't why indentation is required.  You can indent 1
> > space if you want.
> >   
> 
> One space or a hundred, it's still all about appearance.
> 
> 
> > 
> >   
> >>> You can reduce the whitespace somewhat by writing 2-statement
> >>> lines where reasonable.
> >>>
> >>> for i in range(len(d)): p.append(d[i][1])
> >>>
> >>>
> >>> And you can probably change your editor's default tab indentation
> >>> to 2 or 3 spaces, if the standard 4 looks like too much
> >>> whitespace. 
> >> 
> >> Also, python loops are just retarded.
> >> What the hell is wrong with a simple indexed for loop that python
> >> makes you go through this contrived mess:
> >> 
> >> i=0
> >> while i < whatever
> >>   something 
> >>   i+1
> >> 
> >> or else with some bullshit with range() or enumerate().  
> > 
> > 
> > What's wrong with 'for i in range(0,101,10)'?
> > 
> >   
> 
> Do this without jumping through hoops:
> for (i=0; i<count && blah[i]>i ;i++)
> 

Of course while loop is for conditions like that, but for loop is best
used for iterations through container. eg in Rust it is preferred way
and C++ also introduced such. 

-- 
press any key to continue or any other to quit

[toc] | [prev] | [next] | [standalone]


#378199

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-10-27 01:21 +0000
Message-ID<ahjgdki0o03.ae@rooftop.invalid>
In reply to#378190
Melzzzzz <mel@zzzzz.com> wrote:
> On Wed, 26 Oct 2016 20:42:28 +0000 (UTC)
> deplorable owl <owl@rooftop.invalid> wrote:
> 
>> DFS <nospam@dfs.com> wrote:
>> > On 10/26/2016 1:22 AM, deplorable owl wrote:  
>> >> DFS <nospam@dfs.com> wrote:  
>> >>> On 10/22/2016 12:34 PM, deplorable owl wrote:
>> >>>  
>> >>>> I don't like forced indentation.  That's why I don't like
>> >>>> python.  
>> >>>
>> >>>
>> >>> The .py is always right!
>> >>>
>> >>> Consistent indentation improves readability, and as you know code
>> >>> is much more often read than written.
>> >>>
>> >>>
>> >>> Is it actually the forced indenting that bothers you, or the amt
>> >>> of whitespace?
>> >>>  
>> >> 
>> >> No, it's the forced indentation.  I indent my own code most of the
>> >> time  
>> > 
>> > But python forces it, and you're a proud programmer who won't EVER
>> > be told what to do!
>> > 
>> >   
>> >> unless it's really short, but even then while debugging I'll often
>> >> drop in test code left-flushed so that it stands out from the rest.
>> >> I don't need some nanny making me pretty up my code a certain way.
>> >> Why does the freaking source need to have a "look" to it?  If it
>> >> looks bad, reformat before you start to read it.  
>> > 
>> > Appearance isn't why indentation is required.  You can indent 1
>> > space if you want.
>> >   
>> 
>> One space or a hundred, it's still all about appearance.
>> 
>> 
>> > 
>> >   
>> >>> You can reduce the whitespace somewhat by writing 2-statement
>> >>> lines where reasonable.
>> >>>
>> >>> for i in range(len(d)): p.append(d[i][1])
>> >>>
>> >>>
>> >>> And you can probably change your editor's default tab indentation
>> >>> to 2 or 3 spaces, if the standard 4 looks like too much
>> >>> whitespace. 
>> >> 
>> >> Also, python loops are just retarded.
>> >> What the hell is wrong with a simple indexed for loop that python
>> >> makes you go through this contrived mess:
>> >> 
>> >> i=0
>> >> while i < whatever
>> >>   something 
>> >>   i+1
>> >> 
>> >> or else with some bullshit with range() or enumerate().  
>> > 
>> > 
>> > What's wrong with 'for i in range(0,101,10)'?
>> > 
>> >   
>> 
>> Do this without jumping through hoops:
>> for (i=0; i<count && blah[i]>i ;i++)
>> 
> 
> Of course while loop is for conditions like that, but for loop is best
> used for iterations through container. eg in Rust it is preferred way
> and C++ also introduced such. 
> 

Well, depending on how you construct the while loop, it's essentially the
same a for loop.  My basic gripe with python is how unintuitive and tedious
the code is:

C:
for (i=0; i<count && blah[i]>i ;i++)
{
  whatever();
}

vs

Python:
for i,val in enumerate(blah):
  if i<count and blah[i]>i
    whatever()
  i+=1

# same as "if i<count and val>i"

Not to mention how unbelievably slow python is.

For example, with some printing of values:

C array:
   int blah[]={9,8,7,6,5,4,3,2,1,0};

and

Python list:
blah=[9,8,7,6,5,4,3,2,1,0]


anon@lowtide:~/code/for$ ./wah
blah[0]: 9
blah[1]: 8
blah[2]: 7
blah[3]: 6
blah[4]: 5
anon@lowtide:~/code/for$ ./tah.py
blah[0]: 9
blah[1]: 8
blah[2]: 7
blah[3]: 6
blah[4]: 5
anon@lowtide:~/code/for$ 

anon@lowtide:~/code/for$ time ./dowah 1000 >out.wah

real	0m0.409s
user	0m0.024s
sys	0m0.076s
anon@lowtide:~/code/for$ time ./dotah 1000 >out.tah

real	0m11.478s
user	0m7.908s
sys	0m2.120s
anon@lowtide:~/code/for$ 

[toc] | [prev] | [next] | [standalone]


#377282

FromDFS <nospam@dfs.com>
Date2016-10-22 09:33 -0400
Message-ID<nufpqs$6tc$5@dont-email.me>
In reply to#377239
On 10/21/2016 9:06 PM, deplorable owl wrote:
> DFS <nospam@dfs.com> wrote:
>> On 10/21/2016 4:53 AM, deplorable owl wrote:
>>
>>> python pwned by C.
>>
>> I don't see any C.
>>
> 
> The code is at the bottom.

Thanks



> anon@lowtide:~/code/blah$ time ./nah data 15 40 1000 >out
> 
> real    0m0.006s
> user    0m0.004s
> sys     0m0.000s

>    printf("%d %s%s\n\n",n++,quotes,s);



0.006s for 1000 loops and ~15,000 printf() statements?

That seems mighty fast, hombre...


(if you looked closely, my python routines were timed without print
statements so I could compare just the list and string ops)

[toc] | [prev] | [next] | [standalone]


#377305

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-10-22 16:50 +0000
Message-ID<adfjjgue003.gaeg@rooftop.invalid>
In reply to#377282
DFS <nospam@dfs.com> wrote:
> On 10/21/2016 9:06 PM, deplorable owl wrote:
>> DFS <nospam@dfs.com> wrote:
>>> On 10/21/2016 4:53 AM, deplorable owl wrote:
>>>
>>>> python pwned by C.
>>>
>>> I don't see any C.
>>>
>> 
>> The code is at the bottom.
> 
> Thanks
> 
> 
> 
>> anon@lowtide:~/code/blah$ time ./nah data 15 40 1000 >out
>> 
>> real    0m0.006s
>> user    0m0.004s
>> sys     0m0.000s
> 
>>    printf("%d %s%s\n\n",n++,quotes,s);
> 
> 
> 
> 0.006s for 1000 loops and ~15,000 printf() statements?
> 
> That seems mighty fast, hombre...
> 

Compile it and see how it runs on your system.
It must have been caching on mine yesterday.  Today it's averaging in
the 0.020 range today.

Increasing the loop to 100,000 brings it to 0.578, which is
close to the rate I got last night.

> 
> (if you looked closely, my python routines were timed without print
> statements so I could compare just the list and string ops)
> 
> 

That makes your python times even worse.
Time it in python with the prints and redirect output to a file.

If put in clock_gettime() markers before and after the function call
loop, with printfs commented out, my times today are in the 0.009
range, compared to 0.018 otherwise.

Increasing the loop to 100,000 without printfs gives 0.3x
anon@lowtide:~/code/blah$ ./nahtimenowrite data 15 40 100000
elapsed: 0.335349
anon@lowtide:~/code/blah$ ./nahtimenowrite data 15 40 100000
elapsed: 0.337719
anon@lowtide:~/code/blah$ ./nahtimenowrite data 15 40 100000
elapsed: 0.324367
anon@lowtide:~/code/blah$ ./nahtimenowrite data 15 40 100000
elapsed: 0.329019
anon@lowtide:~/code/blah$ 

[toc] | [prev] | [next] | [standalone]


#375321

From"Octavian W. Lagrange" <olagrang@perch.invalid>
Date2016-10-06 21:25 +0000
Message-ID<hjsgue03agu3.ki@perch.invalid>
In reply to#375257
DFS <nospam@dfs.com> wrote:
> And it's another 12-line python program!  How about that?!
> 
> Same as before, the challenge is to replicate the functionality in 
> another programming language.
> 
> Even though it's a tiny bit of code, I know all 3 of y'all will whine a 
> LOT, so this time I'll give you more hints.
> 
> --------------------------------------------------------
> def splitByLength(t,n,m):
>        w=str(t).split()
>        s,q=0,''
>        if w[0][0]=='>':
>                q=w[0]+' '
>                w.pop(0)
>        for e in range(1,len(w)-1):
>                if w[e][-1:]=='.':w[e]+=' '
>                if len(q)+len(' '.join(w[s:e+1]))>=m:
>                         print n,q+' '.join(w[s:e])
>                         n+=1; s=e
>        print n,q+' '.join(w[s:len(w)])
> --------------------------------------------------------
> 
> t = input text
> n = starting number
> m = max length of lines
> w = list object
> s = integer to keep track of position
> q = quoter character >
> e = integer to keep track of position
> 
> 
> 
> Example input:
> 
> txt = "> Intel doesn't have to write a kernel from scratch. Nor does 
> Android.  They can use Linux. And if they need to make modifications for 
> their own benefit, that's fine, just share that back. They benefited by 
> not having to develop from scratch. But they need to give something back 
> in return.  Like the work they added. Both parties are give and take 
> something from each other. I'll take that over the BSD license any day 
> of the week."
> 
> 
> Output of splitByLength(txt,1,60):
> 
> 1 > Intel doesn't have to write a kernel from scratch.  Nor
> 2 > does Android.  They can use Linux.  And if they need to
> 3 > make modifications for their own benefit, that's fine,
> 4 > just share that back.  They benefited by not having to
> 5 > develop from scratch.  But they need to give something
> 6 > back in return.  Like the work they added.  Both parties
> 7 > are give and take something from each other.  I'll take
> 8 > that over the BSD license any day of the week.
> 
> 
> Output of splitByLength(txt,100,40):
> 
> 100 > Intel doesn't have to write a kernel
> 101 > from scratch.  Nor does Android.
> 102 > They can use Linux.  And if they need
> 103 > to make modifications for their own
> 104 > benefit, that's fine, just share that
> 105 > back.  They benefited by not having
> 106 > to develop from scratch.  But they
> 107 > need to give something back in
> 108 > return.  Like the work they added.
> 109 > Both parties are give and take
> 110 > something from each other.  I'll take
> 111 > that over the BSD license any day of
> 112 > the week.
> 
> 
> 
> 
> 
> Now wake those little dummies of yours and tell them there's work to do!
> 

4 line bash function.  12 line complete program.

[toc] | [prev] | [next] | [standalone]


#375434

FromSandman <mr@sandman.net>
Date2016-10-07 16:30 +0000
Message-ID<sandman-a760f940a1b1f2162684108351e2e40b@individual.net>
In reply to#375257
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In article <nt5rdf$35m$2@dont-email.me>, DFS wrote:

> And it's another 12-line python program!  How about that?!

> Same as before, the challenge is to replicate the functionality in 
> another programming language.

> Even though it's a tiny bit of code, I know all 3 of y'all will
> whine a LOT, so this time I'll give you more hints.

> --------------------------------------------------------
> def splitByLength(t,n,m):
> w=str(t).split()
> s,q=0,''
> if w[0][0]=='>':
> q=w[0]+' '
> w.pop(0)
> for e in range(1,len(w)-1):
> if w[e][-1:]=='.':w[e]+=' '
> if len(q)+len(' '.join(w[s:e+1]))>=m:
> print n,q+' '.join(w[s:e])
> n+=1; s=e
> print n,q+' '.join(w[s:len(w)])
> --------------------------------------------------------

> t = input text
> n = starting number
> m = max length of lines
> w = list object
> s = integer to keep track of position
> q = quoter character >
> e = integer to keep track of position

PHP, one line script:

#######
  print "> " . wordwrap($argv[1], $argv[2] ?: 60, "\n> ", false) . "\n";
#######

# ~> ./wordwrap.php "DFS is sure using a lot of lines of codes to do simple things" 20 

# > DFS is sure using a
# > lot of lines of
# > codes to do simple
# > things


# ~> ./wordwrap.php "DFS is sure using a lot of lines of codes to do simple things" 40 

# > DFS is sure using a lot of lines of
# > codes to do simple things


(I added a "# " to the pasted text to not confuse quote level scripts)

Add another line to the script to handle already quoted text, let me know if you want to see 
it :)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQEcBAEBAgAGBQJX983AAAoJECFEwfBaA+jREPMH/11bfSHPPCgfxJDth0o3fFLX
dDcSAPMmrDONHFYOJiiqOxkdoTi0kll6aAkWf2o96T4zggxf9Oi5cZCPWPzyM5Re
89lMVmPZa6kVmtc7GsaS67qtD8Vyd3+aW3NbKY1zV4dFRLGauQrw548SkGVZoh6p
9feILJva4PSy/300/FTdeOWrRzsX2+VZ1rXPdcPvUYDMEgXvLukRuvTkXaxWqX03
srQ31F6NdYJZOWkuuxf4Ao8uvrvnBjMtaaKMigqgshe+9bG/Jwb0eWODt0Li1ymK
tdLcPvqcP6RojCRvIczHsxiM/Ie/PcsXkNLd72lo15ihBURwio1FwmAltMSUFbc=
=Rc2e
-----END PGP SIGNATURE-----


-- 
Sandman

[toc] | [prev] | [next] | [standalone]


#375436

FromSteve Carroll <fretwizzer@gmail.com>
Date2016-10-07 09:44 -0700
Message-ID<c2752fb0-263f-4e51-bf17-b7ed933d9bf1@googlegroups.com>
In reply to#375434
On Friday, October 7, 2016 at 10:30:59 AM UTC-6, Sandman wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> In article <nt5rdf$35m$2@dont-email.me>, DFS wrote:
> 
> > And it's another 12-line python program!  How about that?!
> 
> > Same as before, the challenge is to replicate the functionality in 
> > another programming language.
> 
> > Even though it's a tiny bit of code, I know all 3 of y'all will
> > whine a LOT, so this time I'll give you more hints.
> 
> > --------------------------------------------------------
> > def splitByLength(t,n,m):
> > w=str(t).split()
> > s,q=0,''
> > if w[0][0]=='>':
> > q=w[0]+' '
> > w.pop(0)
> > for e in range(1,len(w)-1):
> > if w[e][-1:]=='.':w[e]+=' '
> > if len(q)+len(' '.join(w[s:e+1]))>=m:
> > print n,q+' '.join(w[s:e])
> > n+=1; s=e
> > print n,q+' '.join(w[s:len(w)])
> > --------------------------------------------------------
> 
> > t = input text
> > n = starting number
> > m = max length of lines
> > w = list object
> > s = integer to keep track of position
> > q = quoter character >
> > e = integer to keep track of position
> 
> PHP, one line script:
> 
> #######
>   print "> " . wordwrap($argv[1], $argv[2] ?: 60, "\n> ", false) . "\n";
> #######
> 

You cheated! You used the ternary ;)


> # ~> ./wordwrap.php "DFS is sure using a lot of lines of codes to do simple things" 20 
> 
> # > DFS is sure using a
> # > lot of lines of
> # > codes to do simple
> # > things
> 
> 
>  # ~> ./wordwrap.php "DFS is sure using a lot of lines of codes to do simple things" 40 
> 
> # > DFS is sure using a lot of lines of
> # > codes to do simple things
> 
> 
> (I added a "# " to the pasted text to not confuse quote level scripts)
> 
> Add another line to the script to handle already quoted text, let me know if you want to see 
> it :)
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.12 (GNU/Linux)
> 
> iQEcBAEBAgAGBQJX983AAAoJECFEwfBaA+jREPMH/11bfSHPPCgfxJDth0o3fFLX
> dDcSAPMmrDONHFYOJiiqOxkdoTi0kll6aAkWf2o96T4zggxf9Oi5cZCPWPzyM5Re
> 89lMVmPZa6kVmtc7GsaS67qtD8Vyd3+aW3NbKY1zV4dFRLGauQrw548SkGVZoh6p
> 9feILJva4PSy/300/FTdeOWrRzsX2+VZ1rXPdcPvUYDMEgXvLukRuvTkXaxWqX03
> srQ31F6NdYJZOWkuuxf4Ao8uvrvnBjMtaaKMigqgshe+9bG/Jwb0eWODt0Li1ymK
> tdLcPvqcP6RojCRvIczHsxiM/Ie/PcsXkNLd72lo15ihBURwio1FwmAltMSUFbc=
> =Rc2e
> -----END PGP SIGNATURE-----
> 
> 
> -- 
> Sandman

[toc] | [prev] | [next] | [standalone]


#375438

FromSandman <mr@sandman.net>
Date2016-10-07 17:20 +0000
Message-ID<sandman-2a976c806669036c5a6d2798ddf05f99@individual.net>
In reply to#375436
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In article <c2752fb0-263f-4e51-bf17-b7ed933d9bf1@googlegroups.com>, Steve 
Carroll wrote:

> > Sandman:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> 
> > > DFS:
> > > And it's another 12-line python program! How about that?! Same
> > > as before, the challenge is to replicate the functionality in
> > > another programming language. Even though it's a tiny bit of
> > > code, I know all 3 of y'all will whine a LOT, so this time I'll
> > > give you more hints.
> > > -------------------------------------------------------- def
> > > splitByLength(t,n,m): w=str(t).split() s,q=0,'' if w[0][0]=='>':
> > > q=w[0]+' ' w.pop(0) for e in range(1,len(w)-1): if
> > > w[e][-1:]=='.':w[e]+=' ' if len(q)+len(' '.join(w[s:e+1]))>=m:
> > > print n,q+' '.join(w[s:e]) n+=1; s=e print n,q+'
> > > '.join(w[s:len(w)])
> > > -------------------------------------------------------- t =
> > > input text n = starting number m = max length of lines w = list
> > > object s = integer to keep track of position q = quoter
> > > character > e = integer to keep track of position
> > 
> > Sandman:
> > PHP, one line script: ####### print ">" . wordwrap($argv[1],
> > $argv[2] ?: 60, "\n>", false) . "\n"; #######
> 
> You cheated! You used the ternary ;)

Yeah, listening to DFS, you get the notion that he expects every single value 
to be assigned to a discrete variable, or it's cheating or something :)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQEcBAEBAgAGBQJX99lPAAoJECFEwfBaA+jR3AQH/RT/+S8N4Q3zu4nQnvTPAmiU
9v6YjwOiFdLGWlqCmbseemJs1SLnI3GKylVTyFrT4u5IeC6paSDh9QnxO0kPzvI6
5CJTT8dkViudChpOk8xC7yJZuepGU6PavpV6tY2j0ERLY3fYjIWY2MkeEydLnUiV
8GZk61rDY4fRlg321TuAm5kiMiLBh/eheqZ6F3g6BO2+W9ZxUO3Jlpivv3/rvAjL
BYEfivz7inR2wt+S35i8ur75lpqmeggzW4jEEjtIj/EV+Ouy90+lQKKDqISU0QI9
moa5+AdY2X9klN55GR8HEAxxvVPqR21zpmEc7NDrBoso2rTonvg3wdIos0WDPH8=
=7WEn
-----END PGP SIGNATURE-----


-- 
Sandman

[toc] | [prev] | [next] | [standalone]


Page 5 of 6 — ← Prev page 1 2 3 4 [5] 6  Next page →

Back to top | Article view | comp.os.linux.advocacy


csiph-web