opshin icon indicating copy to clipboard operation
opshin copied to clipboard

Implement Fractions/Rationals

Open nielstron opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. A lot of sophisticated applications require fractions. This is not native to UPLC and hence not easy to represent in python

Describe the solution you'd like A sample implementation of fractionals similar to the Plutus implementation would be good and simple to use

Optimally, this uses UPLC primitives and is thus fast and efficient.

For the user this should be importable as from fractions import Fraction or something in this direction https://docs.python.org/3/library/fractions.html

Describe alternatives you've considered One could also write a prelude-like implementation of fractions that uses a PlutusData or Tuple Object to represent fractions instead. Since we could exploit the native Pair structure of UPLC though it might make sense to use a native UPLC implementation instead.

Additional context https://github.com/input-output-hk/plutus/blob/master/plutus-tx/src/PlutusTx/Ratio.hs https://github.com/Plutonomicon/pluto/blob/main/examples/field-of-rationals.pluto

nielstron avatar Feb 01 '23 15:02 nielstron

The current workaround is #108

nielstron avatar Apr 04 '23 12:04 nielstron