Re: Problems running some EmuLisp tests with ersatz

2014-04-17 Thread Alexander Burger
Hi Christophe,

thanks for the input! :)


 1) Regarding this snippet: (for ((I . N) 11 (not (= I 4)) (inc N)) (list I N))
 the official PicoLisp and ersatz 27 return (4 14),
 but ersatz 29 (currently the most recent version) returns (3 13).

Correct. This was fixed a while ago, on Tue Oct 02 09:16:10 2012
(Increment 'for' counter before the condition).

But while testing this, I found the miniPicoLisp was faulty here. I
fixed and uploaded it now.



 2) Regarding the sort function, ersatz (both versions) is OK with
 (let L (3 'Y Y 'X 3 X NIL) (sort L))
 but throws a java.lang.StackOverflow with :
 (let L (3 'Y Y 'X 3 X NIL) (sort L ))

Oops, yes! I've fixed it. It is now in 3.1.6.5 JVM.

Thanks again!
♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: nooby question re lists and quoting

2014-04-17 Thread Simon Luetzelschwab
Thanks for the response Mansur and Henrik - much appreciated.

Mansur - Great, this looks much better!

Henrik - I have been looking ath the articles on ProDevTips and some of the
libs on bitbucket - very helpful as well.

What I'm really trying to do is have an easy way to invoke arbitrary shell
commands that may be piped, process the result in pico and maybe use that
as the input for another command.

I haven't found a generic example yet that doesn't specify the command
specifically that allows arbitrary piping and still gives you access to
intermediary results.

Feel free to point me to any additional examples that go beyond calling one
hardcoded command.

Thanks again and I'm sure I'll be back with more questions!

Best,
Simon


On Wed Apr 16 2014 at 10:02:09 PM, Henrik Sarvell hsarv...@gmail.com
wrote:

 Hi Simon, this is similar to stuff in my own system command helper
 script, I use it a lot:
 https://bitbucket.org/hsarvell/ext/src/tip/cmd.l?at=default

 It might give you some ideas.

 On Thu, Apr 17, 2014 at 10:13 AM,   wrote:
  Hi, Simon,
 
  you can use apply here:
 
  (de exe2 (X)
 (apply 'call X) )
 
  because call needs multiple arguments, but not one list.
 
  Best regards,
  Mansur Mamkin
 
  17.04.2014 7:17, Simon Luetzelschwab пишет:
 
  Hi,
 
  PicoLisp is my first LISP dialect and I'm trying to move some of the
  things I do on the command line to PicoLisp's REPL and scripts.
 
  I'm playing around with pipes, in, out and call and have a basic
 question:
 
  If I have the following fun -
 
  (de exe (X)
  (eval (cons 'call X)) )
 
  I can call it as follows -
 
  (exe '(ls -l))
 
  However, if I've defined it as -
 
  (de exe2 (X)
  (call X) )
 
  I can't figure out how to call exe2.
 
  (exe2 '(ls -l))
  ls-l: Can't exec
  - NIL
 
  I'm pretty sure I shouldn't be using eval for such a case, but can't
  figure it out.
 
  Any insight much appreciated.
 
  Best,
  Simon
 
  PS: I checked the reference, online docs and Henrik's Ext / cmd.l lib
 
  --
  UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
 --
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe



Re: nooby question re lists and quoting

2014-04-17 Thread Henrik Sarvell
Hi Simon, if we take the classic ps aux | grep X

Obviously you can just input one function into the next like this: (println
(excmd~exe (excmd~script 'ps T 'aux) T 'grep 'bash))

Not so elegant, so I added this to cmd.l:

(de chain @
   (let Str (in (next) (till NIL T))
  (while (next)
 (setq Str (pipe (out @ (prin Str)) (till NIL T ) )

So you can do like this: (println (excmd~chain '(ps aux) '(grep bash)))

But actually being able to do something like this might be more useful:

(println (excmd~chain
'(ps aux)
'((L) (pack L hijacked with a bash^Jand another line with a
bash))
'(grep bash)
'((L) (mapcar pack (split L ^J))) ) )

So I updated the above function to look like this:

(de chain @
   (let Str (in (next) (till))
  (while
 (let? L (next)
(setq Str
   (if (or (sym? L) (lst? (car L)))
  (L Str)
  (pipe (out L (prin (if (str? Str) Str (pack Str
(till)) ) ) ) )
  Str ) )

More to your likening?




On Thu, Apr 17, 2014 at 9:50 PM, Simon Luetzelschwab simo...@gmail.comwrote:

 Thanks for the response Mansur and Henrik - much appreciated.

 Mansur - Great, this looks much better!

 Henrik - I have been looking ath the articles on ProDevTips and some of
 the libs on bitbucket - very helpful as well.

 What I'm really trying to do is have an easy way to invoke arbitrary shell
 commands that may be piped, process the result in pico and maybe use that
 as the input for another command.

 I haven't found a generic example yet that doesn't specify the command
 specifically that allows arbitrary piping and still gives you access to
 intermediary results.

 Feel free to point me to any additional examples that go beyond calling
 one hardcoded command.

 Thanks again and I'm sure I'll be back with more questions!

 Best,
 Simon


 On Wed Apr 16 2014 at 10:02:09 PM, Henrik Sarvell hsarv...@gmail.com
 wrote:

 Hi Simon, this is similar to stuff in my own system command helper
 script, I use it a lot:
 https://bitbucket.org/hsarvell/ext/src/tip/cmd.l?at=default

 It might give you some ideas.

 On Thu, Apr 17, 2014 at 10:13 AM,   wrote:
  Hi, Simon,
 
  you can use apply here:
 
  (de exe2 (X)
 (apply 'call X) )
 
  because call needs multiple arguments, but not one list.
 
  Best regards,
  Mansur Mamkin
 
  17.04.2014 7:17, Simon Luetzelschwab пишет:
 
  Hi,
 
  PicoLisp is my first LISP dialect and I'm trying to move some of the
  things I do on the command line to PicoLisp's REPL and scripts
 
  I'm playing around with pipes, in, out and call and have a basic
 question:
 
  If I have the following fun -
 
  (de exe (X)
  (eval (cons 'call X)) )
 
  I can call it as follows -
 
  (exe '(ls -l))
 
  However, if I've defined it as -
 
  (de exe2 (X)
  (call X) )
 
  I can't figure out how to call exe2.
 
  (exe2 '(ls -l))
  ls-l: Can't exec
  - NIL
 
  I'm pretty sure I shouldn't be using eval for such a case, but can't
  figure it out.
 
  Any insight much appreciated.
 
  Best,
  Simon
 
  PS: I checked the reference, online docs and Henrik's Ext / cmd.l lib
 
  --
  UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
 --
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe




Re: nooby question re lists and quoting

2014-04-17 Thread Alexander Burger
Hi Simon,

 What I'm really trying to do is have an easy way to invoke arbitrary shell
 commands that may be piped, process the result in pico and maybe use that
 as the input for another command.
 
 I haven't found a generic example yet that doesn't specify the command
 specifically that allows arbitrary piping and still gives you access to
 intermediary results.

The most general way is to use the 'in' function in combination with an
invocation of the system shell ('bash' usually). This has more overhead
than direcly calling commands, but allows you to use all features of the
shell.

For example

   (in (list sh -c (pack cmd1 -i Var1  -x  Var2  | cmd2))
  (while (line)
 ... ) )

Here the 'while' loop assumes that there are no empty lines. Instead you
may want to do

  (until (eof)
 ...
 (line)
 ... )

It is hard to give a general rule, it depends a lot on what you want to
do. Perhaps you can post a concrete problem?

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


Re: nooby question re lists and quoting

2014-04-17 Thread Simon Luetzelschwab
Awesome! Thanks Henrik and Alex.

Henrik - Yes, that's what I was envisioning. Thank you for the quick update
to the repository.

Alex - I hadn't thought about calling a shell - thanks for pointing this
out!

The main use case is that I'm calling a combination of command line tools
to pull in data that can be represented as text and I need to do some
postprocessing such as aggregations or comparisons of the same data at
different snapshots.

I've traditionally been using a combination of awk, sed, grep and small
python snippets and the various internal command line tools my company has
to access and process the data.

These are mostly ad hoc, but it's always nice to be able to replicate the
process on a fresh data set at a later point without much effort.

Maybe I should also mention that I'm coming from a mostly
Java/JavaScript/Python background and have been on a journey exploring
Scala, some Clojure, Common LISP and now PicoLisp. I've been most impressed
by PicoLisp and it's general philosophy of simplicity and not imposing any
restrictions on its user - it's been a very humbling, but rewarding
experience so far.

Thanks again for the warm welcome everyone and I'm always interested in
learning how others incorporate Pico into their workflow.

Best,
Simon

On Thu Apr 17 2014 at 10:16:16 AM, Alexander Burger a...@software-lab.de
wrote:

 Hi Simon,

  What I'm really trying to do is have an easy way to invoke arbitrary
 shell
  commands that may be piped, process the result in pico and maybe use that
  as the input for another command.
 
  I haven't found a generic example yet that doesn't specify the command
  specifically that allows arbitrary piping and still gives you access to
  intermediary results.

 The most general way is to use the 'in' function in combination with an
 invocation of the system shell ('bash' usually). This has more overhead
 than direcly calling commands, but allows you to use all features of the
 shell.

 For example

(in (list sh -c (pack cmd1 -i Var1  -x  Var2  | cmd2))
   (while (line)
  ... ) )

 Here the 'while' loop assumes that there are no empty lines. Instead you
 may want to do

   (until (eof)
  ...
  (line)
  ... )

 It is hard to give a general rule, it depends a lot on what you want to
 do. Perhaps you can post a concrete problem?

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



Re: Problems running some EmuLisp tests with ersatz

2014-04-17 Thread Christophe Gragnic
On Thu, Apr 17, 2014 at 8:00 AM, Alexander Burger a...@software-lab.de wrote:
 1) Regarding this snippet: (for ((I . N) 11 (not (= I 4)) (inc N)) (list I 
 N))
 the official PicoLisp and ersatz 27 return (4 14),
 but ersatz 29 (currently the most recent version) returns (3 13).

 Correct. This was fixed a while ago, on Tue Oct 02 09:16:10 2012
 (Increment 'for' counter before the condition).

Ha ha, funny that I trusted the real, but ancient, PicoLisp.
Even more funny: I now understand that the number 27 or 29 is not the version
but the (fake) pointer of the (version) function in ersatz.

 Oops, yes! I've fixed it. It is now in 3.1.6.5 JVM.

 Thanks again!

Thanks to you for the quick fix.


chri

-- 

http://profgra.org/lycee/ (site pro)
http://delicious.com/profgraorg (liens, favoris)
https://twitter.com/profgraorg
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe