[ProgClub programming] jsphp.co: new bcmod function

John Elliot jj5 at progclub.org
Sat Mar 17 13:30:37 EST 2012


I was working on some software and I found myself wanting a version of
the PHP bcmod function (basically arbitrary precision modulus operator)
in JavaScript. So I went to jsphp.co to download it, only to discover
that this function hadn't been implemented yet. So I implemented it.

Over the course of the evening I went from my first version at
2012-03-16 19:27 UTC:

 http://jsphp.co/jsphp/fn/view/bcmod/462

To a version that I felt comfortable releasing by 2012-03-17 02:09 UTC:

 http://jsphp.co/jsphp/fn/view/bcmod/518

So about six hours, you can see my progress here:

 http://jsphp.co/jsphp/version/view/bcmod

And you can see the diff between the first and last versions here:

 http://jsphp.co/jsphp/fn/diff/bcmod?a=462&b=518

I configured bcmod to use the 'abs' and 'array_reverse' functions as
dependencies:

 http://jsphp.co/jsphp/dependency/view/bcmod

I wrote 50 unit tests:

 http://jsphp.co/jsphp/test/view/bcmod/43

And they all pass:

 http://jsphp.co/jsphp/fn/test/bcmod

It feels so good having the infrastructure I need to get things done in
place, and now I have my bcmod function, and jsphp.co is just that
little bit better.

John.

p.s. if you think my code stinks and you could do a better job of
commenting or picking variable names or algorithms then swing by and
create yourself an account and get hacking! http://jsphp.co/






More information about the programming mailing list