Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Don't feed the bats tonight.


comp / comp.lang.scheme / Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )

SubjectAuthor
* Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )HenHanna
`* Re: Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )Sebastian Wells
 `- Re: Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )Lawrence D'Oliveiro

1
Subject: From JoyceUlysses.txt -- words occurring exactly once
From: HenHanna
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Thu, 30 May 2024 20:09 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: HenHanna@devnull.tb (HenHanna)
Newsgroups: comp.lang.lisp,comp.lang.scheme
Subject: From JoyceUlysses.txt -- words occurring exactly once
Date: Thu, 30 May 2024 13:09:39 -0700
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <v3ame4$1qf6m$5@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 30 May 2024 22:09:40 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f52218980f176c0dd32f4029d8d739d1";
logging-data="1916118"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6rzA6AzKlnTXYGNmst5paZRpzqsYOmIE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:WgFTgUR9FsrgTqElm82oqyLLD7c=
Content-Language: en-US
View all headers

i'd not use Gauche for this, but maybe someone can change my mind.

_______________________
From JoyceUlysses.txt -- words occurring exactly once

Given a text file of a novel (JoyceUlysses.txt) ...

could someone give me a pretty fast (and simple) program that'd give me
a list of all words occurring exactly once?

-- Also, a list of words occurring once, twice or 3 times

re: hyphenated words (you can treat it anyway you like)

ideally, i'd treat [editor-in-chief]
[go-ahead] [pen-knife]
[know-how] [far-fetched] ...
as one unit.

Subject: Re: Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )
From: Sebastian Wells
Newsgroups: comp.lang.python, comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Mon, 24 Jun 2024 05:38 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: sebastian@here.com.invalid (Sebastian Wells)
Newsgroups: comp.lang.python,comp.lang.lisp,comp.lang.scheme
Subject: Re: Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in
Python )
Date: Mon, 24 Jun 2024 05:38:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <v5b0nv$7182$2@dont-email.me>
References: <v3bkoj$23bck$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 24 Jun 2024 07:38:09 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2787d93bb44b66d3fe4dceb9b5d2d9b9";
logging-data="230658"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19nWfyBbmhvNTwzRsJsvg95qXPQLQZoZpY="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:rY5rTbmDHhSEpwBJxSIfuFOT+1A=
View all headers

On Thu, 30 May 2024 21:47:14 -0700, HenHanna wrote:

> ;;; Pls tell me about little tricks you use in Python or Lisp.
>
>
> [('the', 36225), ('and', 17551), ('of', 16759), ('i', 16696), ('a',
> 15816), ('to', 15722), ('that', 11252), ('in', 10743), ('it', 10687)]
>
> ((the 36225) (and 17551) (of 16759) (i 16696) (a 15816) (to 15722) (that
> 11252) (in 10743) (it 10687))
>

The direct Lispification of the original expression would probably be
something like this:

#(#("the" 36225) #("and" 17551) #("of" 16759)
#("i" 16696) #("a" 15816))

...etc, taking into account that Python "lists" are really
arrays, and there's no real Lisp equivalent to tuples,
but they're essentially arrays also. And there's a distinction
between strings and symbols in Lisp that could be approximated
in Python by defining an empty class for each desired symbol.
But since strings are used in the Python example, they should
be used in the Lisp one, too.

That written, there's not much benefit in doing this in a Python
program, and you actually lose one of the advantages you started
out with: Like Lisp, the Python syntax is readable Python. Unlike
Lisp, there's no reader that will give you the original structure
from its string representation without having to also evaluate it
as code. Lispifying it doesn't bring that advantage unless you
also implement a reader, and even then you might be better off
convincing some insider to endorse a Python analogue to JSON. But
that insider would probably tell you to use JSON, ignoring
the lack of distinct array/tuple types in JSON, or he'd tell you
to use Pickle, ignoring the fact that it's a binary format.

Norvig was coping big time. He even called Python an "acceptable"
compromise between what Lisp delivers and whatever it is that's
supposed to be good about Python that it didn't directly copy
from Lisp.

Subject: Re: Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )
From: Lawrence D'Oliv
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Mon, 24 Jun 2024 05:42 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.lisp,comp.lang.scheme
Subject: Re: Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in
Python )
Date: Mon, 24 Jun 2024 05:42:56 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <v5b10v$pqf9$1@dont-email.me>
References: <v3bkoj$23bck$1@dont-email.me> <v5b0nv$7182$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 24 Jun 2024 07:42:56 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3048fea01d51f9337586ac8e02824e6c";
logging-data="846313"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bnC0OyY21ppsAZ4YnOUyE"
User-Agent: Pan/0.158 (Avdiivka; )
Cancel-Lock: sha1:1ElHD1KcZ4/yWke/QgOJqSiPSQM=
View all headers

On Mon, 24 Jun 2024 05:38:07 -0000 (UTC), Sebastian Wells wrote:

> Unlike Lisp,
> there's no reader that will give you the original structure from its
> string representation without having to also evaluate it as code.

If that means what I think it means, it’s wrong. You can indeed compile
Python source to AST form without going all the way to bytecode.

1

rocksolid light 0.9.8
clearnet tor