-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement conversion between arrays, monzos and vals
ref #248
- Loading branch information
Showing
3 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2283,4 +2283,27 @@ describe('Poor grammar / Fun with "<"', () => { | |
); | ||
expect(interval.domain).toBe('logarithmic'); | ||
}); | ||
|
||
it('can convert 81/80 to a prime count array', () => { | ||
const counts = evaluate('toPrimeArray(81/80)') as Interval[]; | ||
expect(counts.map(i => i.toInteger())).toEqual([-4, 4, -1]); | ||
}); | ||
|
||
it('can convert [-4, 4, -1] to a monzo', () => { | ||
const {interval, fraction} = parseSingle( | ||
'monzoFromPrimeArray([-4, 4, -1])' | ||
); | ||
expect(fraction).toBe('81/80'); | ||
expect(interval.toString()).toBe('[-4 4 -1>'); | ||
}); | ||
|
||
it('can convert [email protected] to a prime mapping array', () => { | ||
const map = evaluate('toPrimeArray([email protected])') as Interval[]; | ||
expect(map.map(i => i.toInteger())).toEqual([12, 19, 28]); | ||
}); | ||
|
||
it('can convert [12, 19, 28] to a val', () => { | ||
const val = evaluate('valFromPrimeArray([12, 19, 28])') as Val; | ||
expect(val.toString()).toBe('<12 19 28]'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters