Need help with list of fractions

M

Matthew Wilson

Hi-


I have a list of floats. The list will always be 2^x+1 values, sorted,
between 0 and 1.

The smallest list would be [0, 0.5, 1].

I need a function that can get a list of any length, and return a new
list. For example:
[0, 1/3.0, 2/3.0, 1]
foo([0, 1/4.0, 1/2.0, 3/4.0, 1])
[0, 1/5.0, 2/5.0, 3/5.0, 4/5.0, 1]

The output list will have 1 more element than the input list.

I can't (be bothered to) figure out how foo should work internally. Maybe
somebody can help? This stuff is not my strong suit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top