I added my class that makes a rotate random based on a function.
Added a operator for liquidsoap for make a module based rotator, and now i
will try to make a "function" based rotation in the liquidsoap after i solve
the mod issue.

In the attachments is the patch file.

Em 5 de outubro de 2011 20:48, Fábio Costa <blackjackde...@gmail.com>escreveu:

> I could made what i wanted without the exception , since i need to browse
> the whole list.
> But i understood that the exception is not the wrong way of do things.
> Thanks for the example
>
>
> 2011/10/5 Romain Beauxis <to...@rastageeks.org>
>
>> 2011/10/5 David Baelde <david.bae...@gmail.com>:
>> > Hi Fabio,
>>
>> Hi all!
>>
>> > Using exceptions in that kind of code is not wrong, and it's more
>> > efficient. Without it, we would have to continue the folding over the
>> > rest of the list, even though we already know what we've found. By
>> > raising an exception, we interrupt that computation and jump directly
>> > to the handler.
>> >
>> > Exceptions in OCaml are very fast, pretty much a goto/longjmp. This is
>> > why (unlike in other languages) they can be used in interesting ways
>> > as a programming construct, and not only for errors / exceptional
>> > cases.
>>
>> Not to be pedantic, but the truth is also that fold_left provides a
>> quick way to implement what you want, therefore we use exceptions to
>> make use of it.
>>
>> You could do it without exceptions and with a tail-recursive function this
>> way:
>>
>> let rec f result list =
>>  match list with
>>      | x :: list' ->
>>           let result' = (something about x and result.. ) in
>>           if (for some reason I shall stop) then
>>             result'
>>           else
>>             f result' list'
>>      | [] ->
>>     (here it depends: maybe return result,
>>      or assert false, or..)
>>  in
>>  let result = f 0 list in
>>  (...)
>>
>> If you are interested into this, we could continue that discussion on
>> -devl. In particular, tail-recursive functions are very important in
>> OCaml..
>>
>> Romain
>>
>
>

Attachment: switch.patch
Description: Binary data

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Savonet-devl mailing list
Savonet-devl@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/savonet-devl

Répondre à