Doing functional stuff in ChucK can be pretty fun (and verbose), but for specifically switch-case structures, mostly these can be implemented e.g. asif(var == 0) // case 0:{ }else if(var == 1) // case 1:{ }else // default:{ }You can't do fall-throughs or nutty things like Duff's device, but (making up a number) maybe 90% of switch-case uses I see are basically a slightly better-looking if-else. Are you doing something more elaborate than branching on the value of a specific variable?spencer--On Mon, Oct 12, 2015 at 2:22 PM, Forrest Curo <treegestalt@gmail.com> wrote:It looks far prettier than a mess of logical spaghetti!But is this documented with examples for the help & understanding of object-challenged geezers from the days of punch-card boxes converted twice/day to error-message listings?On Mon, Oct 12, 2015 at 10:37 AM, Michael Heuer <heuermh@gmail.com> wrote:_______________________________________________Forrest Curo <treegestalt@gmail.com> wroteAn array of functions, either numbered or associative? How to declare and call such an array?Since switches have so far not been included, is there a way around this?An array of Events?ChucK doesn't have function pointers or similar, so I've resorted to functors
https://github.com/heuermh/lick/blob/master/lick/fnE.g.class DoSomething extends Procedure {fun void run() { ... }}class DoSomethingElse extends Procedure {fun void run() { ... }}DoSomething doSomething;DoSomethingElse doSomethingElse;ArrayList procedures;
procedures.add(doSomething);procedures.add(doSomethingElse);while (true) {procedures.sample() $ Procedure @=> Procedure procedure;procedure.run();1::second => now;}Yeah, it ain't pretty.michael
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Spencer SalazarDoctoral CandidateCenter for Computer Research in Music and AcousticsStanford University
_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users