Fractran: Difference between revisions
m
→{{header|Scheme}}: Added SRFI 13
Simple9371 (talk | contribs) (→{{header|Scheme}}: corrected, but please improve because I'm a complete n00b!) |
Simple9371 (talk | contribs) m (→{{header|Scheme}}: Added SRFI 13) |
||
Line 3,663:
Scheme naturally handles fractions, translating to integers as required.
The first part of the code translates from a string representation, as required, but equally the user could type the list of fractions in directly as a list.
{{libheader|Scheme/SRFIs}}
Similar to Python implementation of generating primes, the power of 2 is detected by first converting the number to binary representation, and check if it has only 1 "1" bit.
<lang scheme>(import (scheme base)
(scheme inexact)
(scheme read)
(scheme write
(srfi 13)) ;; for string-length and string-ref
(define *string-fractions* ; string input of fractions
|