functional programming - Loops in SML/NJ -


I am very new to SNL / NJ and wondering how I can fulfill the following:

  foo (luggage, counter) {while (counter> gt; 0) {bar (luggage); Reply1; } Return; }  

Something like this, but how do I reduce it?:

  foo (luggage, counter) = counter> 0 times (luggage) ??? // How do I reduce the counter?  

I agree with other contributors that you usually refer to Rickshaw instead of loop and mutation Should do so in a functional language to do so.

If you really want to use mutations and loops, then you have to use the data structure that uses a reference that is a type of "volatile cell". You assign references with the ref function, passing it the initial content you ! can access content using the operator. And you set up new content using the : = operator. So the literal translation of the code given above will be as follows: As you can see, the syntax is really ugly and this is another reason why people avoid it.

  Funny foo (luggage, counter-start) = val counter = referee counter- while restarting! Counter & gt; 0 times (bar accessories; counter: =! Counter-1) end;  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -