AM Posted June 28, 2018 Share Posted June 28, 2018 something i've coded... (defun binary-filter (alist bin-list) (let ((event-list (cond ((omn-formp alist) (single-events alist)) (t alist)))) (flatten (loop for i in event-list for j in bin-list when (= j 1) collect i else append (cond ((omn-formp i) (list (length-invert (car i)))) ((lengthp i) (neg! (omn :length (list i))))))))) (binary-filter '(q -q -q q) '(0 1 0 1)) => (-1/4 -q -1/4 q) (binary-filter '(q q q q -q) '(0 1 0 1 1)) => (-1/4 q -1/4 q -q) (binary-filter '(c4 d4 e4 f4) '(1 1 0 1)) => (c4 d4 f4) (binary-filter '(q c4 mf d4 e4 e f4 ppp g4 a4 b4) '(1 0 1 1 0 1 1)) => (q c4 mf -1/4 q e4 mf e f4 ppp -1/8 e a4 ppp e b4 ppp) loopyc 1 Quote Link to comment Share on other sites More sharing options...
o_e Posted July 1, 2018 Share Posted July 1, 2018 Hi André Just investigating your function.. Then I've tried a little cosmetic hack to make it more readable, but it did not work out and I don't understand why. What did I overlook? Thanks! ole ;;; the orginal function (defun binary-filter (alist bin-list) (let ((event-list (cond ((omn-formp alist) (single-events alist)) (t alist)))) (flatten (loop for i in event-list for j in bin-list when (= j 1) collect i else append (cond ((omn-formp i) (list (length-invert (car i)))) ((lengthp i) (neg! (omn :length (list i))))))))) (binary-filter '(q c4 mf d4 e4 e f4 ppp g4 a4 b4) '(1 0 1 1 0 1 1)) => (q c4 mf -1/4 q e4 mf e f4 ppp -1/8 e a4 ppp e b4 ppp) ;;;Why is it not working?? (defun foo-rep (n sequence &key omn) (maybe-omn-decode omn (binary-filter n sequence))) (foo-rep '(q c4 mf d4 e4 e f4 ppp g4 a4 b4) '(1 0 1 1 0 1 1) :omn t) -->(q c4 mf -1/4 q e4 mf e f4 ppp -1/8 e a4 ppp e b4 ppp);?? AM 1 Quote Link to comment Share on other sites More sharing options...
opmo Posted July 1, 2018 Share Posted July 1, 2018 (defun binary-filter (alist bin-list &key (omn t)) (let ((event-list (cond ((omn-formp alist) (single-events alist)) (t alist)))) (flatten (loop for i in event-list for j in bin-list when (= j 1) collect i else append (maybe-omn-decode omn (cond ((omn-formp i) (list (length-invert (car i)))) ((lengthp i) (neg! (omn :length (list i)))))))))) (binary-filter '(q c4 mf d4 e4 e f4 ppp g4 a4 b4) '(1 0 1 1 0 1 1)) => (q c4 mf -q q e4 mf e f4 ppp -e e a4 ppp e b4 ppp) Only one type of parameters can be decoded at a time. AM 1 Quote Link to comment Share on other sites More sharing options...
o_e Posted July 1, 2018 Share Posted July 1, 2018 Thank you! Quote Link to comment Share on other sites More sharing options...
AM Posted July 1, 2018 Author Share Posted July 1, 2018 i found an internal function (binary-invert '((1 0) (0 0 1))) => ((0 1) (1 1 0)) Quote Link to comment Share on other sites More sharing options...
o_e Posted July 1, 2018 Share Posted July 1, 2018 how did you found it, it's not documented..? And it works only for binary lists, right? Quote Link to comment Share on other sites More sharing options...
AM Posted July 1, 2018 Author Share Posted July 1, 2018 I wanted to call my own function like that - "Error: The function binary-invert is predefined by Opusmodus." also: (binary-invert '(0 8 0 2 2)) => (1 0 1 0 0) janusz? Quote Link to comment Share on other sites More sharing options...
opmo Posted July 1, 2018 Share Posted July 1, 2018 Predefined functions can't be changed otherwise you would break the system. The binary-invert is sub function of binary-variant. (binary-variant '(0 1 1 0 1 0 1 1) 'i) => (1 0 0 1 0 1 0 0) AM 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.