Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You will win success in whatever calling you adopt.


comp / comp.lang.lisp / Descending

SubjectAuthor
* DescendingB. Pym
`* Re: DescendingHenHanna
 +- Re: Descendingsteve g
 `* Re: DescendingHenHanna
  `- Re: DescendingJeff Barnett

1
Subject: Descending
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Fri, 7 Jun 2024 10:57 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Descending
Date: Fri, 7 Jun 2024 10:57:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <v3up28$21qlk$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Fri, 07 Jun 2024 12:57:15 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="1bc38dad617067a6ea5de53e723fa216";
logging-data="2157236"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19K2cLJo6CqVnuFWmOnM1Fj"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:4Ox/RriAp4ctsCgGnh9nyMotbkA=
View all headers

Ken Tilton wrote:

> > I am having trouble coding a list traversal segment.
> > eg list:
> >
> > (a (b) (c (e (h i)) (f (j))) (d (g)))
> >
> > I want to traverse this list in "preorder" and get the following
> > output:
> >
> > a b c e h i f j d g
> >
> > anyone have a code segment to this?
> >
> > thanks....
> >
> > Chris.
>
> Will this work?:
>
> (defun dump (list-or-atom)
> (if (listp list-or-atom)
> (dolist (loa list-or-atom)
> (dump loa))
> (format t "~s " list-or-atom)))

Gauche Scheme:

(define (dump list-or-atom)
(cond ((null? list-or-atom) )
((list? list-or-atom)
(begin
(dump (car list-or-atom))
(dump (cdr list-or-atom))))
(#t (format #t ":~s " list-or-atom))))

(dump '(a (b) (c (e (h i)) (f (j))) (d (g))))
===>
:a :b :c :e :h :i :f :j :d :g #t

Subject: Re: Descending
From: HenHanna
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Tue, 23 Jul 2024 19:27 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: HenHanna@devnull.tb (HenHanna)
Newsgroups: comp.lang.lisp
Subject: Re: Descending
Date: Tue, 23 Jul 2024 12:27:39 -0700
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <v7p07b$1b339$4@dont-email.me>
References: <v3up28$21qlk$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 23 Jul 2024 21:27:40 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="45120b53e64fc89465e7bcc84dd55152";
logging-data="1412201"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19tBUM+T1BnV3P+xxfEnSXcNNHxSxziU70="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:d1FOy9Jh5OPYYInALBNdiKeidIs=
In-Reply-To: <v3up28$21qlk$1@dont-email.me>
Content-Language: en-US
View all headers

On 6/7/2024 3:57 AM, B. Pym wrote:
>
> Ken Tilton wrote:
>
>>> I am having trouble coding a list traversal segment.
>>> eg list:
>>>
>>> (a (b) (c (e (h i)) (f (j))) (d (g)))
>>>
>>> I want to traverse this list in "preorder" and get the following
>>> output:
>>>
>>> a b c e h i f j d g
>>>
>>> anyone have a code segment to this?
>>>
>>> thanks....
>>>
>>> Chris.

>>
>> Will this work?:
>>
>> (defun dump (list-or-atom)
>> (if (listp list-or-atom)
>> (dolist (loa list-or-atom)
>> (dump loa))
>> (format t "~s " list-or-atom)))
>
> Gauche Scheme:
>
> (define (dump list-or-atom)
> (cond ((null? list-or-atom) )
> ((list? list-or-atom)
> (begin
> (dump (car list-or-atom))
> (dump (cdr list-or-atom))))
> (#t (format #t ":~s " list-or-atom))))
>
> (dump '(a (b) (c (e (h i)) (f (j))) (d (g))))
> ===>
> :a :b :c :e :h :i :f :j :d :g #t
>

(i've added some spaces)

the good ol' Flatten ?

Subject: Re: Descending
From: steve g
Newsgroups: comp.lang.lisp
Date: Sun, 11 Aug 2024 22:51 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 11 Aug 2024 22:51:03 +0000
From: sgonedes1977@gmail.com (steve g)
Newsgroups: comp.lang.lisp
Subject: Re: Descending
References: <v3up28$21qlk$1@dont-email.me> <v7p07b$1b339$4@dont-email.me>
Date: Sun, 11 Aug 2024 18:51:03 -0400
Message-ID: <87ed6u3c88.fsf@gmail.com>
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:yyuPsJPiUqfzcq/tZH6ZuwAA0kY=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 62
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-xfPO5O/ckDAuHnXzJayKhqtiUWgpF9citucllbPY4Sjh2Q1xp6z+Q7ngxhwoQLl3W86wzbPTPrxHj+t!vazjIAc7RDgyMjkAtNQ0lhOYKo/3mYCwJgNIcl0NOFx+74w=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
View all headers

HenHanna <HenHanna@devnull.tb> writes:

> On 6/7/2024 3:57 AM, B. Pym wrote:
< > Ken Tilton wrote:
< >
< >>> I am having trouble coding a list traversal segment.
< >>> eg list:
< >>>
< >>> (a (b) (c (e (h i)) (f (j))) (d (g)))
< >>>
< >>> I want to traverse this list in "preorder" and get the following
< >>> output:
< >>>
< >>> a b c e h i f j d g
< >>>
< >>> anyone have a code segment to this?
< >>>
< >>> thanks....
< >>>
< >>> Chris.
>
>
< >>
< >> Will this work?:
< >>
< >> (defun dump (list-or-atom)
< >> (if (listp list-or-atom)
< >> (dolist (loa list-or-atom)
< >> (dump loa))
< >> (format t "~s " list-or-atom)))
< > Gauche Scheme:
< > (define (dump list-or-atom)
< > (cond ((null? list-or-atom) )
< > ((list? list-or-atom)
< > (begin
< > (dump (car list-or-atom))
< > (dump (cdr list-or-atom))))
< > (#t (format #t ":~s " list-or-atom))))
< > (dump '(a (b) (c (e (h i)) (f (j))) (d (g))))
< > ===>
< > :a :b :c :e :h :i :f :j :d :g #t
< >
>
> (i've added some spaces)
>
> the good ol' Flatten ?

I actually found a reason to use flatten; PDIS systems for rule names!

(defun flatten (l &optional res)
(if (consp l)
(flatten (car l)
(flatten (cdr l) res))
(cons l res)))

(defun generate-flattened-rule-name (pattern)
"Transform <pattern> list into a readable name. Ex (on ?x ? ?y ?z) => ON-?X-?-?Y-?Z ."
(mapconcat #'symbol-name (flatten pattern) "-"))

etc...

Subject: Re: Descending
From: HenHanna
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Mon, 12 Aug 2024 17:29 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: HenHanna@devnull.tb (HenHanna)
Newsgroups: comp.lang.lisp
Subject: Re: Descending
Date: Mon, 12 Aug 2024 10:29:24 -0700
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <v9dgpl$3d793$1@dont-email.me>
References: <v3up28$21qlk$1@dont-email.me> <v7p07b$1b339$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 12 Aug 2024 19:29:26 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="1732fa58404ae6011f4e2312f865f442";
logging-data="3579171"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18KJ2zc5y/3V9AEuSysSvzS20jcP78RNA4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:rpAyLnpuDU6ZqBses+n40VgEx+Y=
Content-Language: en-US
In-Reply-To: <v7p07b$1b339$4@dont-email.me>
View all headers

On 7/23/2024 12:27 PM, HenHanna wrote:
>
> On 6/7/2024 3:57 AM, B. Pym wrote:
>>
>> Ken Tilton wrote:
>>
>>>> I am having trouble coding a list traversal segment.
>>>>          eg list:
>>>>
>>>> (a (b) (c (e (h i)) (f (j))) (d (g)))
>>>>
>>>> I want to traverse this list in "preorder" and get the following
>>>> output:
>>>>
>>>>                  a b c e h i f j d g
>>>>
>>>> anyone have a code segment to this?
>>>>
>>>> thanks....
>>>>
>>>> Chris.
>
>
>>>
>>> Will this work?:
>>>
>>> (defun dump (list-or-atom)
>>>     (if (listp list-or-atom)
>>>        (dolist (loa list-or-atom)
>>>            (dump loa))
>>>        (format t "~s " list-or-atom)))
>>
>> Gauche Scheme:
>>
>> (define (dump list-or-atom)
>>    (cond ((null? list-or-atom) )
>>          ((list? list-or-atom)
>>            (begin
>>              (dump (car list-or-atom))
>>              (dump (cdr list-or-atom))))
>>          (#t (format #t ":~s " list-or-atom))))
>>
>> (dump '(a (b) (c (e (h i)) (f (j))) (d (g))))
>>    ===>
>>           :a :b :c :e :h :i :f :j :d :g          #t
>>
>
> (i've added some spaces)
>
> the good ol'  Flatten ?

is there a convention for printing a Colon ( : ) before something?

Subject: Re: Descending
From: Jeff Barnett
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Mon, 12 Aug 2024 18:33 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jbb@notatt.com (Jeff Barnett)
Newsgroups: comp.lang.lisp
Subject: Re: Descending
Date: Mon, 12 Aug 2024 12:33:08 -0600
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <v9dkha$3dtmf$1@dont-email.me>
References: <v3up28$21qlk$1@dont-email.me> <v7p07b$1b339$4@dont-email.me>
<v9dgpl$3d793$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: base64
Injection-Date: Mon, 12 Aug 2024 20:33:14 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="41dcd76a384dc26e69c3a9e5ffde7985";
logging-data="3602127"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Z832GSBz/jxH1wd3brV3S/WVexQYWapI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:eJV600AxKey4Fbcv+b4ugo4ewsU=
X-Antivirus-Status: Clean
X-Antivirus: AVG (VPS 240812-14, 8/12/2024), Outbound message
In-Reply-To: <v9dgpl$3d793$1@dont-email.me>
Content-Language: en-US
View all headers

On 8/12/2024 11:29 AM, HenHanna wrote:
<SNIP>
> is there a convention for  printing  a Colon ( : )    before  something?
Read up on "packages" in Lisp, particularly about the keyword package.
--
Jeff Barnett

1

rocksolid light 0.9.8
clearnet tor