if bit? is a procedure that takes an item and returns #t if the items is 1 or 0 and #f otherwise

(define bit?
(lambda (item)
(if (equal? item 0)
#t
(if (equal? item 1)
#t
#f))))

how can i use bits? to define roll-out that takes a list of non-negative integers and returns the list where each non-bit has been divided into halves, as shown below. When an odd integer is split into two, the second integer is larger

i.e

(roll-out '(5 8 4 0 2 7 1 11))


(2 3 4 4 2 2 0 1 1 3 4 1 5 6)

You would use the bit? predicate to test the value first, then if it is a single bit, emit the value unchanged; otherwise, perform the split.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.