Hi Adam,
Sorry for the previous post, the content can be deleted, wrong script...my fault
Here the correct one:
;; do the punch sequence
(setf *punch-grid* (list))
(dotimes (vert_punch (ceiling possible_y))
(dotimes (horiz_punch (ceiling possible_x))
(setf *punch-pnt* (make-gpnt2d :x x_start :y y_start))
;(display *punch-pnt*)
(setf *punch-grid* (nreconc `(,*punch-pnt*) *punch-grid*))
(setf x_start (+ x_start tool space))
)
(setf x_start x_base)
(setf y_start (- y_start tool space))
)
(display *punch-grid*)
(SHA_PUNCH :tool_type
:TOOL_TYPE_KEY '(:TOOL_TYPE "sqr_sharp")
:TOOL_KEY '(:LENGTH 10.0)
*punch-grid*
)
The SHA_PUNCH part is the SD command which needs one or more XY-coordinates.
The *punch-grid* gives me
(86.0,14.0
74.0,14.0
...
26.0,86.0
14.0,86.0)
but i need is as a list without the brackets....
regards,
Henk
Hi Henk,
> (SHA_PUNCH :tool_type
> :TOOL_TYPE_KEY '(:TOOL_TYPE "sqr_sharp")
> :TOOL_KEY '(:LENGTH 10.0)
> *punch-grid*
> )
The code looks like Common Lisp but the above appears to be invalid
syntax. Why is the keyword :tool_type not supplied with any value? [In
fact it seems to be supplied :TOOL_TYPE_KEY which means the next keyword
is '(:TOOL_TYPE "sqr_sharp")] You're supposed to supply keyword arguments
in name/value pairs, e.g.:
[1]> (defun test (&key key1 key2))
test
[2]> (test :key1 :key2 "value")
*** - test: keyword arguments in (:key1 :key2 "value") should occur pairwise
(test :key1 nil :key2 "value") would have been OK.
I suspect SHA_PUNCH is determining the significance of the arguments itself
and only using (&rest args) as input. One we confirm you syntax is right I
suspect you simply need to APPLY the list *punch-grid* to SHA_PUNCH just
like one would apply a list of numbers to a function:
An example of the issue:
(+ '(1 2 3)) => *** - argument to + should be a number: (1 2 3)
And the solution, apply the list to the function:
(apply #'+ '(1 2 3)) => 6
I'd appreciate if someone could clarify how one uses apply when a function
also requires keyword arguments.
Regards,
Adam
Adam Warner <······@consulting.net.nz> writes:
> I'd appreciate if someone could clarify how one uses apply when a function
> also requires keyword arguments.
No special cases. Also remember that except for the last argument,
apply can pass arguments to a function in the same manner as funcall:
* (defun foo (x &key y z) (values x y z))
FOO
* (apply #'foo 1 :y 2 (list :z 3))
1
2
3
--
Lars Brinkhoff, Services for Unix, Linux, GCC, PDP-10, HTTP
Brinkhoff Consulting http://www.brinkhoff.se/
Hi Lars Brinkhoff,
>> I'd appreciate if someone could clarify how one uses apply when a function
>> also requires keyword arguments.
>
> No special cases. Also remember that except for the last argument,
> apply can pass arguments to a function in the same manner as funcall:
>
> * (defun foo (x &key y z) (values x y z))
> FOO
> * (apply #'foo 1 :y 2 (list :z 3))
> 1
> 2
> 3
Nice! So this should work for Henk, assuming the keywords are written
correctly:
(apply #'SHA_PUNCH :tool_type
:TOOL_TYPE_KEY '(:TOOL_TYPE "sqr_sharp") TOOL_KEY '(:LENGTH 10.0)
*punch-grid*)
It's a bizarre set of arguments. :tool_type looks like it's missing
a value and TOOL_KEY looks like it should be written :TOOL_KEY
Now I understand why (apply #'concatenate 'string ...) works! Lars thank
you for correctly assessing that I was thinking in terms of special cases.
Regards,
Adam