June 11Jun 11 I really appreciate the addition of bind-index in update v4.0.31506 https://opusmodus.com/forums/topic/4133-opusmodus-4031506-update/#comment-14316. This makes reading and comprehending code much easier. Great - thanks @opmo .Question:@opmo Can bind-index be modified, such that the arrows feature described below is mimicked?This would make code even cleaner (at least in case of functions where x is in first argument position. ;; New syntax v4.0.31506 ;; Example from https://opusmodus.com/forums/topic/4133-opusmodus-4031506-update/#comment-14316 (bind-index 'mat (gen-noise 8 :seed 42) (vector-smooth 0.3 x) (vector-to-pitch '(c3 c5) x) (pitch-transpose 12 x) (tonality-map '(major :map 'octave) x) (make-omn :pitch x :length '(h) :span :pitch)) ; => (h g4 mf g4 f4 c4 a4 f5 a5 c6) ;; Compare with arrows (-<> (gen-noise 8 :seed 42) (vector-smooth 0.3 <>) (vector-to-pitch '(c3 c5) <>) (pitch-transpose 12 <>) (tonality-map '(major :map 'octave) <>) (make-omn :pitch <> :length '(h) :span :pitch)) ; => (h g4 mf g4 f4 c4 a4 f5 a5 c6) ;; Summary: ;; bind-index is functionally equivalent to original arrows-syntax :-) ;; except for the fact that bind-index is more powerful ;; as one can refer to an explicite intermediate pipeline result. ;;; --------------------- ;; But there's one feature which has yet not been ;; carried over from arrows to bind-index ;; ;; arrows has a feature where former pipeline result ;; is implicitely added even if <> is not meantioned ;; this works for functions where <> has 1st argument position (-<> (gen-noise 4 :seed 42) (gen-divide 2 <>) (flatten)) ;; no x here ; => (0.45572352 0.3392996 0.19626139 0.81495554) (bind-index 'x- (gen-noise 4 :seed 42) (gen-divide 2 x) (flatten)) ;; no x here ; => throghs an error as x is missing (bind-index 'x- (gen-noise 4 :seed 42) (gen-divide 2 x) (flatten x)) ;; x included and required currently ; => works ; => (0.45572352 0.3392996 0.19626139 0.81495554)
June 11Jun 11 The bind-index construct is a simple variable assignment and does not attempt to alter standard Common Lisp function forms: (flatten).I am planning to remove the Arrows library from OM. Users who wish to continue using it will need to install and load it separately through Quicklisp.
June 11Jun 11 Author Regading arrows removal: Understood, keeping external dependencies minimal is always a good idea.At the end I am happy that OM has introduced some piping functionality.
June 11Jun 11 Arrows removed in 4.0.31510You find more score example using bind-index macro in the document and links.
June 12Jun 12 I rewrote several scores using the new bind-index feature to demonstrate how it can be used in both simple and more complex scores.Links to the relevant scores can be found at the end of the bind-index documentation - 4.0.31513
Create an account or sign in to comment