<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Spencer,<div><br></div><div>thanks for this very useful piece of information !<div>Of course it would make sense to have functions like Michael showed included in Std or Math,<br><div>but to be able to run your own .ck files automatically at startup is also a feature that is<i> </i>ridiculously useful, do you think it can also be included in the next version of mini-audicle ?</div><div><br></div><div>Cheers,</div><div>Casper<br><div><br></div><div><br><div><div><div><div>On 3 jan. 2013, at 18:00, <a href="mailto:chuck-dev-request@lists.cs.princeton.edu">chuck-dev-request@lists.cs.princeton.edu</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Send chuck-dev mailing list submissions to<br><span class="Apple-tab-span" style="white-space:pre">        </span><a href="mailto:chuck-dev@lists.cs.princeton.edu">chuck-dev@lists.cs.princeton.edu</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br><span class="Apple-tab-span" style="white-space:pre"> </span>https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev<br>or, via email, send a message with subject or body 'help' to<br><span class="Apple-tab-span" style="white-space:pre">   </span>chuck-dev-request@lists.cs.princeton.edu<br><br>You can reach the person managing the list at<br><span class="Apple-tab-span" style="white-space:pre"> </span>chuck-dev-owner@lists.cs.princeton.edu<br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of chuck-dev digest..."<br>Today's Topics:<br><br>   1. Re: add methods to Std or Math (Spencer Salazar)<br><br><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(127, 127, 127, 1.0);"><b>From: </b></span><span style="font-family:'Helvetica'; font-size:medium;">Spencer Salazar <spencer@ccrma.stanford.edu><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(127, 127, 127, 1.0);"><b>Subject: </b></span><span style="font-family:'Helvetica'; font-size:medium;"><b>Re: [chuck-dev] add methods to Std or Math</b><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(127, 127, 127, 1.0);"><b>Date: </b></span><span style="font-family:'Helvetica'; font-size:medium;">3 januari 2013 01:33:47 CET<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(127, 127, 127, 1.0);"><b>To: </b></span><span style="font-family:'Helvetica'; font-size:medium;">ChucK Developer Mailing List <chuck-dev@lists.cs.princeton.edu><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(127, 127, 127, 1.0);"><b>Reply-To: </b></span><span style="font-family:'Helvetica'; font-size:medium;">ChucK Developer Mailing List <chuck-dev@lists.cs.princeton.edu><br></span></div><br><br><div dir="ltr">Hey Michael,<div><br></div><div style="">Yeah, these are super useful functions. I have these and a few others defined in a public class called "Std2" whose source file is in my chugin directory. ChucK executes .ck files in the chugin directory at launch, so they are pretty much available for general usage on my system. I think in the future it would make sense/be easy to have these builtin to the language itself though. </div>
<div style=""><br></div><div style="">spencer</div><div style=""><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 31, 2012 at 12:53 PM, Michael Heuer <span dir="ltr"><<a href="mailto:heuermh@gmail.com" target="_blank">heuermh@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I find myself using the following all the time and was wondering how<br>
difficult it would be to add them to Std or Math<br>
<br>
    fun static int constrain(int value, int min, int max)<br>
    {<br>
        if (value < min)<br>
        {<br>
            return min;<br>
        }<br>
        if (value > max)<br>
        {<br>
            return max;<br>
        }<br>
        return value;<br>
    }<br>
<br>
    fun static float constrainf(float value, float min, float max)<br>
    {<br>
        if (value < min)<br>
        {<br>
           return min;<br>
        }<br>
        if (value > max)<br>
        {<br>
            return max;<br>
        }<br>
        return value;<br>
    }<br>
<br>
    fun static float interp(float value, float sourceMin, float<br>
sourceMax, float targetMin, float targetMax)<br>
    {<br>
        return targetMin + (targetMax - targetMin) * ((value -<br>
sourceMin) / (sourceMax - sourceMin));<br>
    }<br>
<br>
Thanks,<br>
<br>
   michael<br>
_______________________________________________<br>
chuck-dev mailing list<br>
<a href="mailto:chuck-dev@lists.cs.princeton.edu">chuck-dev@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev</a><br>
<br>
</blockquote></div><br></div>
<br><br>_______________________________________________<br>chuck-dev mailing list<br>chuck-dev@lists.cs.princeton.edu<br>https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev<br></blockquote></div><br></div></div></div></div></div></div></body></html>