|
From: Michał H. | K. <mh...@ke...> - 2026-06-11 19:10:32
|
Export N, E, W, S from package TEST1 and use it in TEST2, or otherwise import the symbols. Otherwise you are comparing TEST1::N and TEST::2 for equality; they are not the same symbol, so the set difference will not treat them as equal. Alternatively, just use keywords: :N, :E, :W, :S will work fine. ________________________________ From: Shadrock Uhuru <niy...@gm...> Sent: Thursday, June 11, 2026 4:30 PM To: sbc...@li... <sbc...@li...> Subject: [Sbcl-help] help with packages [Some people who received this message don't often get email from niy...@gm.... Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] ;; ------------------------------------------------------------------------ CL(1): (defpackage test1 (:use :cl) (:export :test)) #<PACKAGE "TEST1"> CL(2): (in-package :test1) #<PACKAGE "TEST1"> TEST1(3): (defun test (test-val) ;; remove items from a list (format t "~%the test-val = ~a " test-val) ;; items to remove (let ((diff-list (set-difference (list 'N 'E 'W 'S) test-val))) ;; remove the items (format t "~%the first item of test-val = ~a "(first test-val)) ;; just to prove we get the function parameter ;; and we can operate on it (format t "~%the diff-list = ~a " diff-list) ;; the resultant list (dolist (each-item diff-list) ;; get each item of resultant list (format t "~%each item = ~a" each-item)))) ;; print item TEST TEST1(4): (test (list 'N 'S)) the test-val = (N S) the first item of test-val = N the diff-list = (W E) each item = W each item = E NIL TEST1(5): (defpackage test2 (:use :cl)) #<PACKAGE "TEST2"> TEST1(6): (in-package :test2) #<PACKAGE "TEST2"> TEST2(7) (test1:test (list 'N 'S)) the test-val = (N S) the first item of test-val = N the diff-list = (S W E N) each item = S each item = W each item = E each item = N NIL TEST2(8): ;; --------------------------------------------- SBCL 2.6.4.openbsd.sbcl-2.6.4 hi everyone the function above works when i call it within the package it was created in but when i call it from another package the call to set-difference appears to get an empty list as its second parameter, as the test function works when called from it home package, i'm assuming that the problem lies with how the packages are set up. can anyone point me to the error in my code. thanks shadrock _______________________________________________ Sbcl-help mailing list Sbc...@li... https://lists.sourceforge.net/lists/listinfo/sbcl-help This e-mail is sent to you from Keepit A/S. Dedicated SaaS Data Protection. VAT: DK30806883, Per Henrik Lings Allé 4, 7., DK-2100 Copenhagen O, Denmark. This e-mail is sent to you directly and is meant for nobody else. If the e-mail contains personal data that Keepit is responsible for and the e-mail was not meant for you, please do not forward, distribute, or copy, i.e. but return the e-mail to sender. Also, do not send the e-mail to a third party without making sure that you have our prior consent. Distribution of this e-mail to unauthorized receivers may have legal consequences. If you have received an e-mail from us and you don't know why, then please refer to our Privacy Policy<https://www.keepit.com/privacy-policy/>. If you do not want to receive more e-mails from us, please contact bus...@ke...<mailto:bus...@ke...>. |