Re: Interning symbols in lib/simul.l

2020-04-12 Thread Bruno Franco
thank you!

On Sun, Apr 12, 2020 at 2:01 AM Mike  wrote:

> > I'm studying lib/sumul.l, specifically the 'grid function.
>
> In my repo you would find a lot of usage examples for grid:
> https://git.envs.net/mpech/tankf33der/
>
> (mike)
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


Re: Interning symbols in lib/simul.l

2020-04-12 Thread Mike
> I'm studying lib/sumul.l, specifically the 'grid function.

In my repo you would find a lot of usage examples for grid:
https://git.envs.net/mpech/tankf33der/

(mike)

--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Interning symbols in lib/simul.l

2020-04-11 Thread Alexander Burger
Hi Bruno,

> I'm studying lib/sumul.l, specifically the 'grid function. I understand how
> it works now, but I have two doubts:
> 
> 1) why are symbols in the grid interned?
> ...
>(if (> DX 26)
>   (box)
>   (intern (pack (char (+ X 96)) Y)) ) )  # why

It is just to conveniently access them by name (e.g. a1 - z1), in programs and
during debugging. For example in "games/chess.l":

   (bookMove 'd2 'd4)

or

   $ pil games/chess.l -main +
   ...
   : (go d2 d4)
   ...
   -> ("BlackPawn" d7 . d5)
   : (show 'd4)
   d4 ((c4 . e4) d3 . d5)
  piece "WhitePawn"
  x 4
  whAtt ("WhiteQueen")
  color
  y 4
   -> d4


> 2) what does the F in FX and FY stand for?
> ...
> (de grid (DX DY FX FY)
> ...
>   (let West (and FX (last Grid))

It stands for "Flag", as these parameters are boolean values.

☺/ A!ex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Interning symbols in lib/simul.l

2020-04-11 Thread Bruno Franco
I'm studying lib/sumul.l, specifically the 'grid function. I understand how
it works now, but I have two doubts:

1) why are symbols in the grid interned?
2) what does the F in FX and FY stand for?

here's the code for reference:

(de grid (DX DY FX FY)
   (let Grid
  (make
 (for X DX
(link
   (make
  (for Y DY
 (set
(link
   (if (> DX 26)
  (box)
  (intern (pack (char (+ X 96)) Y)) ) )  # why
are symbols interned here?
(cons (cons) (cons)) ) ) ) ) ) )
  (let West (and FX (last Grid))
 (for (Lst Grid  Lst)
(let
   (Col (++ Lst)
  East (or (car Lst) (and FX (car Grid)))
  South (and FY (last Col)) )
   (for (L Col  L)
  (with (++ L)
 (set (: 0 1) (++ West))  # west
 (con (: 0 1) (++ East))  # east
 (set (: 0 -1) South) # south
 (con (: 0 -1)# north
(or (car L) (and FY (car Col))) )
 (setq South This) ) )
   (setq West Col) ) ) )
  Grid ) )