Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Space tells matter how to move and matter tells space how to curve. -- Wheeler


devel / comp.lang.scheme / Re: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche, Common Lisp ?

SubjectAuthor
* Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche, CommonHen Hanna
+- Re: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche,Hen Hanna
`* Re: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche, Common Lisp ?Paul Rubin
 `* Re: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche,Hen Hanna
  `- Re: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche, Common Lisp ?Paul Rubin

1
Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche, Common Lisp ?

<a5b68272-c877-42b5-808d-0671766e1539n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=168&group=comp.lang.scheme#168

  copy link   Newsgroups: comp.lang.scheme
X-Received: by 2002:a05:620a:290d:b0:6b5:cecc:1cab with SMTP id m13-20020a05620a290d00b006b5cecc1cabmr3564334qkp.465.1662574528760;
Wed, 07 Sep 2022 11:15:28 -0700 (PDT)
X-Received: by 2002:a25:26d0:0:b0:6a8:fd3a:6b86 with SMTP id
m199-20020a2526d0000000b006a8fd3a6b86mr3651521ybm.268.1662574528556; Wed, 07
Sep 2022 11:15:28 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.scheme
Date: Wed, 7 Sep 2022 11:15:28 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2601:648:8600:4980:0:0:0:4873;
posting-account=YjTkGAoAAAA4_fbAISfvtIqrYbghMeBx
NNTP-Posting-Host: 2601:648:8600:4980:0:0:0:4873
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a5b68272-c877-42b5-808d-0671766e1539n@googlegroups.com>
Subject: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche, Common
Lisp ?
From: henhanna@gmail.com (Hen Hanna)
Injection-Date: Wed, 07 Sep 2022 18:15:28 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1610
 by: Hen Hanna - Wed, 7 Sep 2022 18:15 UTC

Count-Trailing-Zeros(x) ----- Can I use Log(x) to see if X is equal to ( Integer * 10 ^ k) ???

How do you do this in Scheme, Gauche, Common Lisp ?

--------- is there a simple string function that counts the leftmost 0's ???

__________________
Count how many zeros are at the end of an int:

def end_zeros(num):
s = str(num)
return len(s) - len(s.rstrip("0"))

print(end_zeros(10)) # ==> 1
print(end_zeros(101)) # ==> 0
print(end_zeros(245)) # ==> 0
print(end_zeros(100100)) # ==> 2

Re: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche, Common Lisp ?

<7287532b-04d9-433b-beb6-e5dff53ae65dn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=169&group=comp.lang.scheme#169

  copy link   Newsgroups: comp.lang.scheme
X-Received: by 2002:a05:6214:260a:b0:498:f11f:2945 with SMTP id gu10-20020a056214260a00b00498f11f2945mr5112659qvb.69.1662589697013;
Wed, 07 Sep 2022 15:28:17 -0700 (PDT)
X-Received: by 2002:a0d:cb50:0:b0:345:6c7d:f0ef with SMTP id
n77-20020a0dcb50000000b003456c7df0efmr5294725ywd.192.1662589696718; Wed, 07
Sep 2022 15:28:16 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.scheme
Date: Wed, 7 Sep 2022 15:28:16 -0700 (PDT)
In-Reply-To: <a5b68272-c877-42b5-808d-0671766e1539n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:648:8600:4980:0:0:0:4873;
posting-account=YjTkGAoAAAA4_fbAISfvtIqrYbghMeBx
NNTP-Posting-Host: 2601:648:8600:4980:0:0:0:4873
References: <a5b68272-c877-42b5-808d-0671766e1539n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7287532b-04d9-433b-beb6-e5dff53ae65dn@googlegroups.com>
Subject: Re: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche,
Common Lisp ?
From: henhanna@gmail.com (Hen Hanna)
Injection-Date: Wed, 07 Sep 2022 22:28:17 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2259
 by: Hen Hanna - Wed, 7 Sep 2022 22:28 UTC

On Wednesday, September 7, 2022 at 11:15:30 AM UTC-7, Hen Hanna wrote:
> Count-Trailing-Zeros(x) ----- Can I use Log(x) to see if X is equal to ( Integer * 10 ^ k) ???
>
> How do you do this in Scheme, Gauche, Common Lisp ?
>
>
> --------- is there a simple string function that counts the leftmost 0's ???
>
>
>
> __________________
> Count how many zeros are at the end of an int:
>
> def end_zeros(num):
> s = str(num)
> return len(s) - len(s.rstrip("0"))
>
>
> print(end_zeros(10)) # ==> 1
> print(end_zeros(101)) # ==> 0
> print(end_zeros(245)) # ==> 0
> print(end_zeros(100100)) # ==> 2

two ideas:

1. i can use string-skip-right to imitate the Python code above.

2. The following works:

(define (Count-end-0 x)
(cdr (fold-right ce0 '(#t . 0) (string->list (number->string x)))))

(define (ce0 c y)
(if (car y)
(if (char=? c #\0)
(cons #t (+ 1 (cdr y)))
(cons #f (cdr y)))
y))

Re: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche, Common Lisp ?

<87k06ewwd0.fsf@nightsong.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=170&group=comp.lang.scheme#170

  copy link   Newsgroups: comp.lang.scheme
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.scheme
Subject: Re: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche, Common Lisp ?
Date: Wed, 07 Sep 2022 17:19:55 -0700
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <87k06ewwd0.fsf@nightsong.com>
References: <a5b68272-c877-42b5-808d-0671766e1539n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="bc50b34c61a164eb3ca6ed16064b4bb5";
logging-data="383424"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19p34UxObPvocwkwtkRnmCL"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:CyG0wKAhapUJ3Obu22gvMTDQt1E=
sha1:8fW+mgA1I1sn6nDpr0Tu1pkmAio=
 by: Paul Rubin - Thu, 8 Sep 2022 00:19 UTC

Hen Hanna <henhanna@gmail.com> writes:
> --------- is there a simple string function that counts the leftmost
> 0's ???

1. I think you mean rightmost zeros.
2. Converting to a string and counting the '0' chars is pretty ugly.

I'd just use simple arithmetic and tail recursion (the Scheme-ish way
to implement a loop):

(define (nz n)
(define (go n a)
(if (= (remainder n 10) 0)
(go (quotient n 10) (1+ a))
a))
(go n 0))

Re: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche, Common Lisp ?

<eb3104c4-c9b5-41ea-b3ed-57416e15d3ecn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=171&group=comp.lang.scheme#171

  copy link   Newsgroups: comp.lang.scheme
X-Received: by 2002:a05:622a:11c8:b0:343:4d55:3307 with SMTP id n8-20020a05622a11c800b003434d553307mr15062644qtk.306.1662774808152;
Fri, 09 Sep 2022 18:53:28 -0700 (PDT)
X-Received: by 2002:a05:6902:154e:b0:6ae:6b25:dd6 with SMTP id
r14-20020a056902154e00b006ae6b250dd6mr6039600ybu.595.1662774807914; Fri, 09
Sep 2022 18:53:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.scheme
Date: Fri, 9 Sep 2022 18:53:27 -0700 (PDT)
In-Reply-To: <87k06ewwd0.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:648:8601:3e90:0:0:0:29dc;
posting-account=YjTkGAoAAAA4_fbAISfvtIqrYbghMeBx
NNTP-Posting-Host: 2601:648:8601:3e90:0:0:0:29dc
References: <a5b68272-c877-42b5-808d-0671766e1539n@googlegroups.com> <87k06ewwd0.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <eb3104c4-c9b5-41ea-b3ed-57416e15d3ecn@googlegroups.com>
Subject: Re: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche,
Common Lisp ?
From: henhanna@gmail.com (Hen Hanna)
Injection-Date: Sat, 10 Sep 2022 01:53:28 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2033
 by: Hen Hanna - Sat, 10 Sep 2022 01:53 UTC

On Wednesday, September 7, 2022 at 5:20:00 PM UTC-7, Paul Rubin wrote:
> Hen Hanna <henh...@gmail.com> writes:
> > --------- is there a simple string function that counts the leftmost
> > 0's ???
> 1. I think you mean rightmost zeros.
> 2. Converting to a string and counting the '0' chars is pretty ugly.
>
> I'd just use simple arithmetic and tail recursion (the Scheme-ish way
> to implement a loop):
>
> (define (nz n)
> (define (go n a)
> (if (= (remainder n 10) 0)
> (go (quotient n 10) (1+ a))
> a))
> (go n 0))

Thank you.... i wonder where internal definittions (5.3.2. Internal definitions in R7RS)
originally came from.....

Were they in MacLISP ?

Re: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche, Common Lisp ?

<87wnaaom3r.fsf@nightsong.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=172&group=comp.lang.scheme#172

  copy link   Newsgroups: comp.lang.scheme
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.scheme
Subject: Re: Count-Trailing-Zeros(1200) ==> 2 _________ in Scheme, Gauche, Common Lisp ?
Date: Sat, 10 Sep 2022 16:17:44 -0700
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <87wnaaom3r.fsf@nightsong.com>
References: <a5b68272-c877-42b5-808d-0671766e1539n@googlegroups.com>
<87k06ewwd0.fsf@nightsong.com>
<eb3104c4-c9b5-41ea-b3ed-57416e15d3ecn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="66ae6a460fe51a786cbf2a7cdba0dff5";
logging-data="1773427"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+aIqlrXUmPVSUP5lNvPPLx"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:PYHBWX5+1g+A14dXnaQZPRlqKEU=
sha1:uPvyW+nYK5XSjNqwmO2qwl0+o4E=
 by: Paul Rubin - Sat, 10 Sep 2022 23:17 UTC

Hen Hanna <henhanna@gmail.com> writes:
> Thank you.... i wonder where internal definittions (5.3.2. Internal
> definitions in R7RS) originally came from..... Were they in MacLISP ?

I think was possible to write an internal lambda in Maclisp using FLET
but it wouldn't have been idiomatic. Using internal functions like that
is typical of functional programming though, and Scheme was one of the
early promoters of that style.

I never used Maclisp but at least originally, it ran on machines that we
would now consider quite memory constrained. So it might have been more
conventional (though uglier) to use a mutable cell. This is Emacs Lisp
which sort of resembles Maclisp:

(defun nz (n)
(let ((a 0))
(while (= (mod n 10) 0)
(setq a (1+ a)
n (/ n 10)))
a))

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor