blamestross / nimrod-vectors Goto Github PK
View Code? Open in Web Editor NEWVector math library for nimrod.
Vector math library for nimrod.
consider using something like this, to get around static[int] not working in types, instead a vector of two would be Vector[range[0..1]]
and length becomes a static property
type
Vector[R] = object
deltas: array[R, float]
proc initVector* (len:static[int]): auto =
return Vector[range[0 .. <len]]()
proc `[]`* [R] (vec:Vector[R]; idx:R): float =
vec.deltas[idx]
proc `[]=`*[R] (vec:var Vector[R]; idx:R; val:float) =
vec.deltas[idx] = val
proc `$`* [R] (vec:Vector[R]): string =
result = "["
for idx,it in vec.deltas.pairs:
result.add($it)
if idx < vec.deltas.high: result.add ", "
result.add "]"
when isMainModule:
var v = initVector(2)
v[0] = 0.5
v[1] = 1.0
echo v
Congratulations!!!
The GitHub(notreally) team has awarded you with the needed website of the week. If you want to win a lot of FAME and rock EVERYWHERE you go, please follow these steps to claim your new and FREE documentation website:
babel install gh_nimrod_doc_pages
.$ cd path/to/your/git/checkout
$ git checkout --orphan gh-pages
$ git rm -rf .
$ gh_nimrod_doc_pages -b
gh_nimrod_doc_pages.ini
file to contain the following lines:["gh-pages"]
update_html=index.html
doc_dir=docs
branches="""
master
"""
$ gh_nimrod_doc_pages -c .
$ git add . && git commit -v
$ git push --set-upstream origin gh-pages
Enjoy your new FREE website for your project!!!
Disclaimers:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.