Jump to content

Featured Replies

Posted

Hi,

Sorry if this is too basic!! I'm trying really to understand details in the order of evaluation.

In a recursive line, does the inner nest always produce ALL of its elements before passing the list to the outer nest?

 

in the example below I think this is what happens:

 

1. randomize-octaves in the list x, the randomise operates on each element of the list in turn and thus creates a new list

2. evaluate that 5 times, thus creating five list with different octave randomisation because the seed is nil

3. the 5 lists are modified where each sequential element in a list may be repeated three times for each element that is not repeated... ratio 1:3 (so it is 3 times as likely to stutter a value than not, correct?)

 

thank you,

Julio

 

;;here is a simple list of pitches
(setf x '(a3 b3 c3 d3 e3))

;; what I want is for a random octave to be evaluated for each individual note of the list... 
;; so I did this and it seems to work...

(setf exp1 (gen-repeat-seq '(5) 1 3 (gen-eval 5 '(randomize-octaves '(c0 g6) x :seed nil))))
  • Author

Hi J,

 

I think I obtained the result I wanted, but I am not entirely sure I understand the process... I wanted 5 versions of the original list where each element had its 8ve randomised, as opposed to each sub-list being transposed, and I obtained that.

 

I just want to be sure I understand the order of execution of operations upon a list when they are nested. It seems each function is executed completely before moving to the next outer function, thus passing a list to the next function (as opposed to each element in turn, which I think is what happens with a stream). I guess I am confused between streams and lists (which is what I work with in SC and lists here).

 

This is proving to be a hard learning curve, so thanks for your help.

Julio

 

 

 

 

 

Hi Julio,

In my understanding, the order of evaluation of forms is left to right. When we write Macros, we are expected to adhere to this convention. If there is a need to be different, it should be noted clearly.

 

In your example, at the top level, "gen-repeat-seq" will be evaluated after "expl". Within "gen-repeat-seq", after evaluating its first 3 args, evaluation of "gen-eval" will start. Within that "randomize-octaves" takes place, and so on. In other words, "gen-eval"will finish only AFTER "randomize-octaves" finishes; "gen-repeat-seq" will complete only AFTER "gen-eval" completes.

 

Hope this is clear? In some languages, this order is not guaranteed, for example in C++.

 

Regards,

Rangarajan

In continuation of the above reply, try to evaluate the following in your Listener:

 

(and (print 1) (print 2) (print (+ (print 3) (print 4))) "Done")

You should see this:

1 
2 
3 
4 
7 
"Done"

This shows left-to-right evaluation. More importantly, because of nested evaluation, 7 is printed only after 3 and 4

 

 

Regards,

Rangarajan

 

 

Create an account or sign in to comment


Copyright © 2014-2025 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy