Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | First commit, adding new file. Almost working |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | descendants | origin/master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
8e5a99e87b2169712f2737790a5a2004 |
User & Date: | base@atomicules.co.uk 2014-02-05 12:18:45 |
Context
2014-02-06
| ||
10:17 |
Correct qsort1, don't nest gear pairs, build up triples and concat
The qsort1 definition was wrong, hence the comment about the wrong http://www.kevinalbrecht.com/code/joy-mirror/j06prg.html isn't just `swap`, but rather `[swap] dip`. However, before I realised | |
2014-02-05
| ||
12:18 | First commit, adding new file. Almost working check-in: 8e5a99e87b user: base@atomicules.co.uk tags: origin/master, trunk | |
Changes
Added joycog.joy.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | (* joycog.joy *) (* Given two lists of gear sprockets will calculate all ratios *) DEFINE (* Constants. Ultimately these want to be arguments to the programme *) littlegears == [12 13 15 17 19 21 23 26]; biggears == [30 50]; (* Calculate Ratios *) biggear1 == biggears first 1.0 *; biggear2 == biggears second 1.0 *; ratios1 == [biggear1 swap /] map; ratios2 == [biggear2 swap /] map; ratios == littlegears dup ratios2 swap ratios1 concat; (* Make up gear pairs *) (* Since can't find a way to format integer as string, rather than list results as [ [ 4.16667 "50/12" ] ... ], list as [ [ 4.16667 [ 50 12 ] ] ... ] *) pairs1 == [ biggear1 unitlist cons] map; pairs2 == [ biggear2 unitlist cons] map; pairs == littlegears dup pairs2 swap pairs1 concat; (* Zip together *) ratiosandpairs == ratios pairs zip; (* Sort *) qsort1 == [ small ] [ ] [ uncons [[first] unary2 > ] split ] [ swap cons concat ] binrec; sorted == ratiosandpairs sorted. (* Almost working, but list is a bit flattened and includes empty lists *) |