Haskell. Changed things a bit to make more sense in Haskell, allRationals is just a normal list of Rationals. Not 100% happy with this because I don't fully understand the flatTree formula I found on the web...
importData.Ratio(numerator,denominator,(%))dataTreea=Treea(Treea)(Treea)rationalTree::TreeRationalrationalTree=build'(1%1)wherebuild'::Rational->TreeRationalbuild'n=leta=numeratornb=denominatorninTreen(build'(a%(a+b)))(build'((a+b)%b))-- from https://doisinkidney.com/posts/2018-12-18-traversing-graphs.html, idk how it worksflatTree::Treea->[a]flatTreer=frb[]wheref(Treexlr)fwbw=x:fw([l,r]:bw)b[]=[]bqs=foldl(foldrf)bqs[]allRationals::[Rational]allRationals=flatTreerationalTree
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Haskell. Changed things a bit to make more sense in Haskell,
allRationals
is just a normal list of Rationals. Not 100% happy with this because I don't fully understand theflatTree
formula I found on the web...