Re: help with packages
Vasily Postnicov <[email protected]> Thu, 11 Jun 2026 17:43:51 +0300
| Newsgroups | gmane.lisp.steel-bank.general |
|---|---|
| Message-ID | <CADnZ6Bmw1tpKBm29i3DXAGr_Qspgkjg4cEYbeVkiBV4QWGcO6g@mail.gmail.com> |
--===============6815719206956695008== Content-Type: multipart/alternative; boundary="000000000000243c050653fb64d2" --000000000000243c050653fb64d2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable In the first case it's 'test1::n and 'test1::s and in the second case it's 'test2::n and 'test2::s =D0=A7=D1=82, 11 =D0=B8=D1=8E=D0=BD=D1=8F 2026=E2=80=AF=D0=B3. =D0=B2 17:32= , Shadrock Uhuru <[email protected]>: > ;; ----------------------------------------------------------------------= -- > 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 =3D ~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 =3D ~a "(first test-val)) ;= ; > just to prove we get the function parameter > ;; > and we can operate on it > (format t "~%the diff-list =3D ~a " diff-list) ;; > the resultant list > (dolist (each-item diff-list) ;; get each item of > resultant list > (format t "~%each item =3D ~a" each-item)))) ;; print item > > TEST > TEST1(4): (test (list 'N 'S)) > > the test-val =3D (N S) > the first item of test-val =3D N > the diff-list =3D (W E) > each item =3D W > each item =3D 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 =3D (N S) > the first item of test-val =3D N > the diff-list =3D (S W E N) > each item =3D S > each item =3D W > each item =3D E > each item =3D 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 > [email protected] > https://lists.sourceforge.net/lists/listinfo/sbcl-help > --000000000000243c050653fb64d2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto">In the first case it's 'test1::n and 'test1::= s and in the second case it's 'test2::n and 'test2::s</div><div= dir=3D"auto"><br><div class=3D"gmail_quote gmail_quote_container" dir=3D"a= uto"><div dir=3D"ltr" class=3D"gmail_attr">=D0=A7=D1=82, 11 =D0=B8=D1=8E=D0= =BD=D1=8F 2026=E2=80=AF=D0=B3. =D0=B2 17:32, Shadrock Uhuru <<a href=3D"= mailto:[email protected]">[email protected]</a>>:<br></div><blockquote= class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli= d;padding-left:1ex">;; ----------------------------------------------------= --------------------<br> CL(1): (defpackage test1<br> =C2=A0 (:use :cl)<br> =C2=A0 (:export :test))<br> #<PACKAGE "TEST1"><br> <br> CL(2): (in-package :test1)<br> #<PACKAGE "TEST1"><br> <br> TEST1(3):<br> <br> (defun test (test-val)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; remove items from a list<br> =C2=A0 (format t "~%the test-val =3D ~a " test-val) ;; items to r= emove<br> =C2=A0 (let ((diff-list (set-difference (list 'N 'E 'W 'S) = test-val)))=C2=A0 ;; remove the items<br> =C2=A0 =C2=A0 (format t "~%the first item of test-val =3D ~a "(fi= rst=C2=A0 test-val))=C2=A0 ;; just to prove we get the function parameter<b= r> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 ;; and we can operate on it<br> =C2=A0 =C2=A0 (format t "~%the diff-list =3D ~a " diff-list)=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;;= the resultant list<br> =C2=A0 =C2=A0 (dolist (each-item diff-list)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; get each item of resultant list<br> =C2=A0 =C2=A0 (format t "~%each item =3D ~a" each-item))))=C2=A0 = =C2=A0 =C2=A0;; print item<br> <br> TEST<br> TEST1(4): (test (list 'N 'S))<br> <br> the test-val =3D (N S)<br> the first item of test-val =3D N<br> the diff-list =3D (W E)<br> each item =3D W<br> each item =3D E<br> NIL<br> <br> <br> TEST1(5): (defpackage test2<br> =C2=A0 (:use :cl))<br> #<PACKAGE "TEST2"><br> <br> TEST1(6): (in-package :test2)<br> #<PACKAGE "TEST2"><br> <br> TEST2(7) (test1:test (list 'N 'S))<br> <br> the test-val =3D (N S)<br> the first item of test-val =3D N<br> the diff-list =3D (S W E N)<br> each item =3D S<br> each item =3D W<br> each item =3D E<br> each item =3D N<br> NIL<br> <br> TEST2(8):<br> <br> ;; ---------------------------------------------<br> SBCL 2.6.4.openbsd.sbcl-2.6.4<br> <br> hi everyone<br> the function above works when i call it within the package it was created i= n<br> but when i call it from another package the call to set-difference<br> appears to get an empty list as its second parameter,<br> as the test function works when called from it home package,<br> i'm assuming that the problem lies with how the packages are set up.<br= > can anyone point me to the error in my code.<br> thanks shadrock<br> <br> <br> _______________________________________________<br> Sbcl-help mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank">Sbcl-h= [email protected]</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/sbcl-help" rel=3D"n= oreferrer" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/s= bcl-help</a><br> </blockquote></div></div> --000000000000243c050653fb64d2-- --===============6815719206956695008== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============6815719206956695008== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Sbcl-help mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sbcl-help --===============6815719206956695008==--