Comments (8)
@jpellegrini thanks I will make sure to add those to unit tests when will work on that function.
from lips.
fixed the simple case and Started adding tests for bigint + float combination, but still rational need some work:
lips> (expt 1/2 2)
1/4
lips> (expt 2 1/2)
2/1
there is a need to add different root calculations (I'm not sure if Scheme has something like this out of the box, it may be useful to expose).
And also added an exception when invoking expt
on complex numbers since this will require more work, need to think how to handle trigonometry functions, that are required to calculate power operation on complex numbers.
from lips.
Arithmetic error:
;; Returns the arithmetic, geometric, and
;; harmonic means of a nested list of numbers
(define (means ton)
(letrec*
((mean
(lambda (f g)
(f (/ (sum g ton) n))))
(sum
(lambda (g ton)
(if (null? ton)
(+)
(if (number? ton)
(g ton)
(+ (sum g (car ton))
(sum g (cdr ton)))))))
(n (sum (lambda (x) 1) ton)))
(values (mean values values)
(mean exp log)
(mean / /))))
Note that evaluating (means '(3 (1 4)))
returns three values: 8/3, 2.28942848510666 (approximately), and 36/19.
LIPS devel returns:
8/3
2.2894284851066633
8/3
Ref: https://small.r7rs.org/wiki/R7RSSmallErrata/
from lips.
Function (means '(3 (1 4)))
is fixed the problem was that (/ 2)
was returning 2
and it was even in doc string. According to spec it should return 1/2
.
from lips.
Hi,
Not sure if this is supposed to be working already (I see expt
is not marked in your checklist), but anyway - (expt 1.5 0)
and (expt 2 3.0)
return an error saying that LIPS can't convert BigInt to number...
from lips.
there is a need to add different root calculations (I'm not sure if Scheme has something like this out of the box, it may be useful to expose).
R7RS has only square roots... I usually do (expt x 1/n)
for the n-th root.
And also added an exception when invoking expt on complex numbers since this will require more work, need to think how to handle trigonometry functions, that are required to calculate power operation on complex numbers.
Maybe (expt x y)
could be implemented as (exp (* (log x) y))
, if you already have log
for complexes?
And (log z)
, with z
complex, would be
REAL: (log (magnitude z))
IMAG: (angle z)
from lips.
Maybe
(expt x y)
could be implemented as(exp (* (log x) y))
, if you already havelog
for complexes?
See PR #247
And I see you already have implemented complex log
...
from lips.
@jpellegrini expt
was fully implemented and fully tested. It will be released in the next beta version.
It matches the implementation of Kawa and doesn't have rounding errors when the power is an integer.
from lips.
Related Issues (20)
- You should be able to unquote-splice list on object literals HOT 1
- You can't define a variable that starts with syntax-extension HOT 1
- inexact->exact on complex literal without real value
- Don't make named let as letrec HOT 1
- Add #!fold-case directive
- You can't define syntax extension that starts with #f and is followed by symbol
- Consider removing macro syntax extensions HOT 1
- some and every should accept more than one list
- Web REPL Mobile support
- V8 Iterator helpers
- fs.readFile doesn't work
- Add doc strings to all SRFI
- You should be able to easily load from lips scheme module directory HOT 1
- Accessing __parser__ from syntax-extension doesn't work from std lib
- syntax-parameterize expression, use body expression that is not hygiene HOT 2
- macroexpand and nested syntax-rules HOT 2
- Build exe file for the REPL
- ESLint stopped working HOT 1
- Improper syntax-rules patterns
- Create an instance of anonymous class HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lips.