From: Elvis Nguyen
Subject: Loop in Let
Date: 
Message-ID: <29bc2cb5-f3c9-40a9-960d-3d08abc0f904@g23g2000vbr.googlegroups.com>
Hi all,

I have a pieces of code below:
(defun bio-graph-gui ()
  (with-ltk ()
    (let* ((sc (make-instance 'scrolled-canvas))
           (c (canvas sc))
           (i))

      ((loop for i in '(10 20 30) do
            (create-line c (list 10 10 100 i)))
       (text (create-text c 260 250 "Canvas test"))
       (pack sc :expand 1 :fill :both)
       (scrollregion c 0 0 800 800)))))

I compile in SBCL, there is always an error at:
(loop for i in '(10 20 30) do
            (create-line c (list 10 10 100 i)))
with the message: illegal function call. I don't understand why? Help
me please

Best regards,

From: Pascal Costanza
Subject: Re: Loop in Let
Date: 
Message-ID: <7buev2F250o5oU1@mid.individual.net>
Elvis Nguyen wrote:
> Hi all,
> 
> I have a pieces of code below:
> (defun bio-graph-gui ()
>   (with-ltk ()
>     (let* ((sc (make-instance 'scrolled-canvas))
>            (c (canvas sc))
>            (i))
> 
>       ((loop for i in '(10 20 30) do
>             (create-line c (list 10 10 100 i)))
>        (text (create-text c 260 250 "Canvas test"))
>        (pack sc :expand 1 :fill :both)
>        (scrollregion c 0 0 800 800)))))
> 
> I compile in SBCL, there is always an error at:
> (loop for i in '(10 20 30) do
>             (create-line c (list 10 10 100 i)))
> with the message: illegal function call. I don't understand why? Help
> me please

There is one pair of parentheses too many: Instead of ((loop ...)), just 
say (loop ...).

Why did you add the extra parentheses?


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Elvis Nguyen
Subject: Re: Loop in Let
Date: 
Message-ID: <b24626c5-8389-428f-b272-a52ee733bb42@r36g2000vbn.googlegroups.com>
On Jul 12, 5:48 pm, Pascal Costanza <····@p-cos.net> wrote:
> Elvis Nguyen wrote:
> > Hi all,
>
> > I have a pieces of code below:
> > (defun bio-graph-gui ()
> >   (with-ltk ()
> >     (let* ((sc (make-instance 'scrolled-canvas))
> >            (c (canvas sc))
> >            (i))
>
> >       ((loop for i in '(10 20 30) do
> >             (create-line c (list 10 10 100 i)))
> >        (text (create-text c 260 250 "Canvas test"))
> >        (pack sc :expand 1 :fill :both)
> >        (scrollregion c 0 0 800 800)))))
>
> > I compile in SBCL, there is always an error at:
> > (loop for i in '(10 20 30) do
> >             (create-line c (list 10 10 100 i)))
> > with the message: illegal function call. I don't understand why? Help
> > me please
>
> There is one pair of parentheses too many: Instead of ((loop ...)), just
> say (loop ...).
>
> Why did you add the extra parentheses?
>
> Pascal
>
> --
> My website:http://p-cos.net
> Common Lisp Document Repository:http://cdr.eurolisp.org
> Closer to MOP & ContextL:http://common-lisp.net/project/closer/

Because, I want to draw some lines in the canvas. Is there any way to
draw some lines using loops.
Step 1: Create a canvas (let * ((....)), called c
Step 2: Draw some lines using Loop
Step 3: Pack these lines into the canvas c.

But it doesn't run.
From: Elvis Nguyen
Subject: Re: Loop in Let
Date: 
Message-ID: <4ae1c24d-725b-4802-a1e4-86f8a6596e5a@33g2000vbe.googlegroups.com>
On Jul 12, 7:11 pm, Elvis Nguyen <·······@gmail.com> wrote:
> On Jul 12, 5:48 pm, Pascal Costanza <····@p-cos.net> wrote:
>
>
>
> > Elvis Nguyen wrote:
> > > Hi all,
>
> > > I have a pieces of code below:
> > > (defun bio-graph-gui ()
> > >   (with-ltk ()
> > >     (let* ((sc (make-instance 'scrolled-canvas))
> > >            (c (canvas sc))
> > >            (i))
>
> > >       ((loop for i in '(10 20 30) do
> > >             (create-line c (list 10 10 100 i)))
> > >        (text (create-text c 260 250 "Canvas test"))
> > >        (pack sc :expand 1 :fill :both)
> > >        (scrollregion c 0 0 800 800)))))
>
> > > I compile in SBCL, there is always an error at:
> > > (loop for i in '(10 20 30) do
> > >             (create-line c (list 10 10 100 i)))
> > > with the message: illegal function call. I don't understand why? Help
> > > me please
>
> > There is one pair of parentheses too many: Instead of ((loop ...)), just
> > say (loop ...).
>
> > Why did you add the extra parentheses?
>
> > Pascal
>
> > --
> > My website:http://p-cos.net
> > Common Lisp Document Repository:http://cdr.eurolisp.org
> > Closer to MOP & ContextL:http://common-lisp.net/project/closer/
>
> Because, I want to draw some lines in the canvas. Is there any way to
> draw some lines using loops.
> Step 1: Create a canvas (let * ((....)), called c
> Step 2: Draw some lines using Loop
> Step 3: Pack these lines into the canvas c.
>
> But it doesn't run.
===========================================
This is code:
;;; Using ltk for making GUIs
(defun bio-graph-gui ()
  (with-ltk ()
    (let* ((sc (make-instance 'scrolled-canvas))
           (c (canvas sc))

           (loop for i from 1 to 3 do (create-line c (list 10 10 100
(* i 100))))
           (text (create-text c 260 250 "Canvas test")))

      (pack sc :expand 1 :fill :both)
      (scrollregion c 0 0 800 800))))

The error is:
The LET* binding spec(loop for i from 1 to 3 do (create-line c (list
10 10 100 (* i 100)))) is malformed.
From: Elvis Nguyen
Subject: Re: Loop in Let
Date: 
Message-ID: <84604379-434b-4fbc-8ecf-a80317873ddf@f10g2000vbf.googlegroups.com>
On Jul 12, 7:20 pm, Elvis Nguyen <·······@gmail.com> wrote:
> On Jul 12, 7:11 pm, Elvis Nguyen <·······@gmail.com> wrote:
>
> > On Jul 12, 5:48 pm, Pascal Costanza <····@p-cos.net> wrote:
>
> > > Elvis Nguyen wrote:
> > > > Hi all,
>
> > > > I have a pieces of code below:
> > > > (defun bio-graph-gui ()
> > > >   (with-ltk ()
> > > >     (let* ((sc (make-instance 'scrolled-canvas))
> > > >            (c (canvas sc))
> > > >            (i))
>
> > > >       ((loop for i in '(10 20 30) do
> > > >             (create-line c (list 10 10 100 i)))
> > > >        (text (create-text c 260 250 "Canvas test"))
> > > >        (pack sc :expand 1 :fill :both)
> > > >        (scrollregion c 0 0 800 800)))))
>
> > > > I compile in SBCL, there is always an error at:
> > > > (loop for i in '(10 20 30) do
> > > >             (create-line c (list 10 10 100 i)))
> > > > with the message: illegal function call. I don't understand why? Help
> > > > me please
>
> > > There is one pair of parentheses too many: Instead of ((loop ...)), just
> > > say (loop ...).
>
> > > Why did you add the extra parentheses?
>
> > > Pascal
>
> > > --
> > > My website:http://p-cos.net
> > > Common Lisp Document Repository:http://cdr.eurolisp.org
> > > Closer to MOP & ContextL:http://common-lisp.net/project/closer/
>
> > Because, I want to draw some lines in the canvas. Is there any way to
> > draw some lines using loops.
> > Step 1: Create a canvas (let * ((....)), called c
> > Step 2: Draw some lines using Loop
> > Step 3: Pack these lines into the canvas c.
>
> > But it doesn't run.
>
> ===========================================
> This is code:
> ;;; Using ltk for making GUIs
> (defun bio-graph-gui ()
>   (with-ltk ()
>     (let* ((sc (make-instance 'scrolled-canvas))
>            (c (canvas sc))
>
>            (loop for i from 1 to 3 do (create-line c (list 10 10 100
> (* i 100))))
>            (text (create-text c 260 250 "Canvas test")))
>
>       (pack sc :expand 1 :fill :both)
>       (scrollregion c 0 0 800 800))))
>
> The error is:
> The LET* binding spec(loop for i from 1 to 3 do (create-line c (list
> 10 10 100 (* i 100)))) is malformed.

Ok, thanks a lot. It works well.
From: Carl Taylor
Subject: Re: Loop in Let
Date: 
Message-ID: <%ap6m.110813$d36.80543@bgtnsc04-news.ops.worldnet.att.net>
"Elvis Nguyen" <·······@gmail.com> wrote in message 
·········································@33g2000vbe.googlegroups.com...
On Jul 12, 7:11 pm, Elvis Nguyen <·······@gmail.com> wrote:
> On Jul 12, 5:48 pm, Pascal Costanza <····@p-cos.net> wrote:
> But it doesn't run.


===========================================
This is code:
;;; Using ltk for making GUIs
(defun bio-graph-gui ()
  (with-ltk ()
    (let* ((sc (make-instance 'scrolled-canvas))
           (c (canvas sc))

           (loop for i from 1 to 3 do (create-line c (list 10 10 100
(* i 100))))
           (text (create-text c 260 250 "Canvas test")))

      (pack sc :expand 1 :fill :both)
      (scrollregion c 0 0 800 800))))


Close the list of variables being bound via the LET with a right paren, 
i.e. ...(c (canvas sc))) and then check to make sure all the parens in 
the code balance properly.

You are attempting to treat LOOP itself as a variable in the LET list.

You want a structure like this:

(let ((a x)
       (b y))
   (loop for i .........)))

A LOOP in LET means the LOOP must be within the scope of the LET not in 
its list of variables.


Carl Taylor
From: Pascal J. Bourguignon
Subject: Re: Loop in Let
Date: 
Message-ID: <87my79iwuh.fsf@galatea.local>
Elvis Nguyen <·······@gmail.com> writes:

> This is code:
> ;;; Using ltk for making GUIs
> (defun bio-graph-gui ()
>   (with-ltk ()
>     (let* ((sc (make-instance 'scrolled-canvas))
>            (c (canvas sc))
>
>            (loop for i from 1 to 3 do (create-line c (list 10 10 100
> (* i 100))))
>            (text (create-text c 260 250 "Canvas test")))
>
>       (pack sc :expand 1 :fill :both)
>       (scrollregion c 0 0 800 800))))
>
> The error is:
> The LET* binding spec(loop for i from 1 to 3 do (create-line c (list
> 10 10 100 (* i 100)))) is malformed.

Even stranger.  Why do you want to define variables named LOOP and
TEST?

The syntax to define a variable is 

  (let* (
           (variable expression)
           ...
        )
     body-expressions...)

so why are you putting several expressions in the variable LOOP
definition clause?

You could write: 

  (let* ((sc  (make-instance 'scrolled-canvas))
         (c   (canvas sc))
         (loop 3)
         (text (create-text c 260 250 "Canvas test")))
    (dotimes (i loop) 
      (create-line c (list 10 10 100 (* i 100))))
    (pack sc :expand 1 :fill :both)
    (scroll-region c 0 800 800))


-- 
__Pascal Bourguignon__
From: Pascal J. Bourguignon
Subject: Re: Loop in Let
Date: 
Message-ID: <87tz1hixa5.fsf@galatea.local>
Elvis Nguyen <·······@gmail.com> writes:

> On Jul 12, 5:48�pm, Pascal Costanza <····@p-cos.net> wrote:
>> Elvis Nguyen wrote:
>> > Hi all,
>>
>> > I have a pieces of code below:
>> > (defun bio-graph-gui ()
>> > � (with-ltk ()
>> > � � (let* ((sc (make-instance 'scrolled-canvas))
>> > � � � � � �(c (canvas sc))
>> > � � � � � �(i))
>>
>> > � � � ((loop for i in '(10 20 30) do
>> > � � � � � � (create-line c (list 10 10 100 i)))
>> > � � � �(text (create-text c 260 250 "Canvas test"))
>> > � � � �(pack sc :expand 1 :fill :both)
>> > � � � �(scrollregion c 0 0 800 800)))))
>>
>> > I compile in SBCL, there is always an error at:
>> > (loop for i in '(10 20 30) do
>> > � � � � � � (create-line c (list 10 10 100 i)))
>> > with the message: illegal function call. I don't understand why? Help
>> > me please
>>
>> There is one pair of parentheses too many: Instead of ((loop ...)), just
>> say (loop ...).
>>
>> Why did you add the extra parentheses?
>
> Because, I want to draw some lines in the canvas. Is there any way to
> draw some lines using loops.
> Step 1: Create a canvas (let * ((....)), called c
> Step 2: Draw some lines using Loop
> Step 3: Pack these lines into the canvas c.
>
> But it doesn't run.

No, Pascal asked why you wrote:

      ((loop for i in '(10 20 30) do
            (create-line c (list 10 10 100 i)))
       (text (create-text c 260 250 "Canvas test"))
       (pack sc :expand 1 :fill :both)
       (scrollregion c 0 0 800 800)))))

instead of:

      (loop for i in '(10 20 30) do
           (create-line c (list 10 10 100 i)))
      (text (create-text c 260 250 "Canvas test"))
      (pack sc :expand 1 :fill :both)
      (scrollregion c 0 0 800 800))))

What made you put these forms inside a list?


-- 
__Pascal Bourguignon__