[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: I'd like some help with a project I'm doing.

William James

6/8/2015 2:24:00 AM

M. Antoniotti wrote:

> > interested) and part of the project was to read in a data file and
> > parse it.
> >
> > The data file is of the form:
> > 3,88,58,11,54,24.8,0.267,22,0
> > 6,92,92,0,0,19.9,0.188,28,0
> > 1,103,80,11,82,19.4,0.491,22,0
> > 1,101,50,15,36,24.2,0.526,26,0
> > ........
> >
> > and I need to get into the form:
> > ((3 88 58 11 54 24.8 0.267 22 0)
> > (6 92 92 0 0 19.9 0.188 28 0)
> > (1 103 80 11 82 19.4 0.491 22 0)
> > (1 101 50 15 36 24.2 0.526 26 0)
> > ........)
> >
> > I have no trouble reading the file and selecting whatever line I want,
> > I just can't parse it into the form (x x x x x x x x x x). I tried
> > using:
> >
> > (read-from-string "1,93,70,31,0,30.4,0.315,23,0")
> >
>
> You need a "parser" for the string.
>
> 1 - split the string at the commas
>
> (split-sequence "1,93,70,31,0,30.4,0.315,23,0" :separator #\,)
>
> this will yield the list of strings
>
> ("1" "93" "70" "31" "0" "30.4" "0.315" "23" "0")
>
> let's call it 'result'.
>
> 2 - transform it into a list of numbers
>
> (mapcar #'read-from-string result)
>
> this yields
>
> (1 93 70 31 0 30.4 0.315 23 0)
>
> you are almost done.
>
> Of course you need SPILT-SEQUENCE. You can find it in many places
> like the CLOCC and ccLan.

Gauche Scheme:

(map string->number (string-split "1,93,70,31,0,30.4,0.315,23,0" #\,))

===>
(1 93 70 31 0 30.4 0.315 23 0)

--
However, we shall see that The Authoritarian Personality extends beyond the
attempt to pathologize cohesive gentile groups to pathologizing adaptive gentile
behavior in general. The principal intellectual difficulty is that behavior
that is critical to Judaism as a successful group evolutionary strategy is
conceptualized as pathological in gentiles. --- Kevin MacDonald; "The Frankfurt
School of Social Research and the Pathologization of Gentile Group Allegiances"
1 Answer

William James

2/1/2016 9:05:00 PM

0

WJ wrote:

> M. Antoniotti wrote:
>
> > > interested) and part of the project was to read in a data file and
> > > parse it.
> > >
> > > The data file is of the form:
> > > 3,88,58,11,54,24.8,0.267,22,0
> > > 6,92,92,0,0,19.9,0.188,28,0
> > > 1,103,80,11,82,19.4,0.491,22,0
> > > 1,101,50,15,36,24.2,0.526,26,0
> > > ........
> > >
> > > and I need to get into the form:
> > > ((3 88 58 11 54 24.8 0.267 22 0)
> > > (6 92 92 0 0 19.9 0.188 28 0)
> > > (1 103 80 11 82 19.4 0.491 22 0)
> > > (1 101 50 15 36 24.2 0.526 26 0)
> > > ........)
> > >
> > > I have no trouble reading the file and selecting whatever line I want,
> > > I just can't parse it into the form (x x x x x x x x x x). I tried
> > > using:
> > >
> > > (read-from-string "1,93,70,31,0,30.4,0.315,23,0")
> > >
> >
> > You need a "parser" for the string.
> >
> > 1 - split the string at the commas
> >
> > (split-sequence "1,93,70,31,0,30.4,0.315,23,0" :separator #\,)
> >
> > this will yield the list of strings
> >
> > ("1" "93" "70" "31" "0" "30.4" "0.315" "23" "0")
> >
> > let's call it 'result'.
> >
> > 2 - transform it into a list of numbers
> >
> > (mapcar #'read-from-string result)
> >
> > this yields
> >
> > (1 93 70 31 0 30.4 0.315 23 0)
> >
> > you are almost done.
> >
> > Of course you need SPILT-SEQUENCE. You can find it in many places
> > like the CLOCC and ccLan.
>
> Gauche Scheme:
>
> (map string->number (string-split "1,93,70,31,0,30.4,0.315,23,0" #\,))
>
> ===>
> (1 93 70 31 0 30.4 0.315 23 0)

MatzLisp (Ruby):

"1,93,70,31,0,30.4,0.315,23,0".split(",").
map{|s| Integer(s) rescue Float(s)}

[1, 93, 70, 31, 0, 30.4, 0.315, 23, 0]

--
Viewed at its most abstract level, a fundamental agenda is thus to influence
the European-derived peoples of the United States to view concern about their
own demographic and cultural eclipse as irrational and as an indication of
psychopathology. --- Dr. Kevin MacDonald; "The Frankfurt School of Social
Research and the Pathologization of Gentile Group Allegiances"