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


Groups > comp.lang.forth > #60717 > unrolled thread

Rosetta: Van der Corput sequence

Started by"Robert L." <No_spamming@noWhere_7073.org>
First post2017-06-14 10:57 +0000
Last post2017-06-14 10:57 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.forth


Contents

  Rosetta: Van der Corput sequence "Robert L." <No_spamming@noWhere_7073.org> - 2017-06-14 10:57 +0000

#60717 — Rosetta: Van der Corput sequence

From"Robert L." <No_spamming@noWhere_7073.org>
Date2017-06-14 10:57 +0000
SubjectRosetta: Van der Corput sequence
Message-ID<ohr4rc$88f$1@gioia.aioe.org>
(use streams)
(use streams-math)

(define base 2)

(define powers (stream-iterate (cut * base <>) base))

(define (digits n)
  (stream-unfold (cut modulo <> base) positive? (cut quotient <> base) n))

(define (vdc n) (stream-sum (stream-map / (digits n) powers)))

(define vdc-stream (stream-map vdc (stream-from 0)))

(stream->list 12 vdc-stream)

 ===>
(0 0.5 0.25 0.75 0.125 0.625 0.375 0.875 0.0625 0.5625 0.3125 0.8125)

In Forth?

-- 
I wrote until my fingers were blue, over and over: "Political
Correctness is a religion."  I proved it and showed you why it is so
important that Political Correctness is a religion.
 --- Bob Whitaker

[toc] | [standalone]


Back to top | Article view | comp.lang.forth


csiph-web