Shen video appeal - generating type secure Python

2013-08-16 Thread Mark Tarver
Shen is a hypermodern functional programming language based on a core that is 
essentially a Lisp, but portable to many major language platforms. One of these 
platforms is Python. I am asking for support for the Shen project in this video 
appeal

www.shenlanguage.org/appeal.html

The video explains the important work taking place in the Shen group and what 
we hope to achieve. Essentially we will be able to generate type-secure Python 
programs which can be run independently within the Python environment. 

We're asking Python programmers to support us in the production of this 
technology.  

with thanks

Mark Tarver
www.shenlanguage.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a little parsing challenge ☺

2011-07-20 Thread Mark Tarver
On Jul 17, 8:47 am, Xah Lee xah...@gmail.com wrote:
 2011-07-16

 folks, this one will be interesting one.

 the problem is to write a script that can check a dir of text files
 (and all subdirs) and reports if a file has any mismatched matching
 brackets.

 • The files will be utf-8 encoded (unix style line ending).

 • If a file has mismatched matching-pairs, the script will display the
 file name, and the  line number and column number of the first
 instance where a mismatched bracket occures. (or, just the char number
 instead (as in emacs's “point”))

 • the matching pairs are all single unicode chars. They are these and
 nothing else: () {} [] “” ‹› «» 【】 〈〉 《》 「」 『』
 Note that ‘single curly quote’ is not consider matching pair here.

 • You script must be standalone. Must not be using some parser tools.
 But can call lib that's part of standard distribution in your lang.

 Here's a example of mismatched bracket: ([)], (“[[”), ((, 】etc. (and
 yes, the brackets may be nested. There are usually text between these
 chars.)

 I'll be writing a emacs lisp solution and post in 2 days. Ι welcome
 other lang implementations. In particular, perl, python, php, ruby,
 tcl, lua, Haskell, Ocaml. I'll also be able to eval common lisp
 (clisp) and Scheme lisp (scsh), Java. Other lang such as Clojure,
 Scala, C, C++, or any others, are all welcome, but i won't be able to
 eval it. javascript implementation will be very interesting too, but
 please indicate which and where to install the command line version.

 I hope you'll find this a interesting “challenge”. This is a parsing
 problem. I haven't studied parsers except some Wikipedia reading, so
 my solution will probably be naive. I hope to see and learn from your
 solution too.

 i hope you'll participate. Just post solution here. Thanks.

  Xah

Parsing technology based on BNF enables an elegant solution.  First
take a basic bracket balancing program which parenthesises the
contents of the input.  e.g. in Shen-YACC

(defcc br
   ( br ) br$ := [br | br$];
   item br;
   e := [];)

(defcc br$
  br;)

(defcc item
  -*- := (if (element? -*- [( )]) (fail) [-*-]);)

Given (compile br [( 1 2 3 ) 4]) the program produces [[1 2 3]
4]. When this program is used to parse the input, whatever residue is
left indicates where the parse has failed.  In Shen-YACC

(define tellme
  Stuff - (let Br (br (@p Stuff []))
Residue (fst Br)
(if (empty? Residue)
(snd Br)
(error parse failure at position ~A~%
  (- (length Stuff) (length Residue))

e.g.

(tellme [( 1 2 3 ) ( 4])
parse failure at position 5

(tellme [( 1 2 3 ) ( ) 4])
[[1 2 3] [] 4]

The extension of this program to the case described is fairly simple.
Qi-YACC is very similar.

Nice problem.

I do not have further time to correspond right now.

Mark
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fascinating interview by Richard Stallman at KTH on emacs history and internals

2010-07-16 Thread Mark Tarver
On 15 July, 23:21, bolega gnuist...@gmail.com wrote:
 http://www.gnu.org/philosophy/stallman-kth.html

 RMS lecture at KTH (Sweden), 30 October 1986

 (Kungliga Tekniska Högskolan (Royal Institute of Technology))
 Stockholm, Sweden

 Arranged by the student society
 “Datorföreningen Stacken”
 30 October 1986

 [Note: This is a slightly edited transcript of the talk. As such it
 contains false starts, as well as locutions that are natural in spoken
 English but look strange in print. It is not clear how to correct them
 to written English style without ‘doing violence to the original
 speech’.]

 It seems that there are three things that people would like me to talk
 about. On the one hand I thought that the best thing to talk about
 here for a club of hackers, was what it was like at the MIT in the old
 days. What made the Artificial Intelligence Lab such a special place.
 But people tell me also that since these are totally different people
 from the ones who were at the conference Monday and Tuesday that I
 ought to talk about what's going on in the GNU project and that I
 should talk about why software and information can not be owned, which
 means three talks in all, and since two of those subjects each took an
 hour it means we're in for a rather long time. So I had the idea that
 perhaps I could split it in to three parts, and people could go
 outside for the parts they are not interested in, and that then when I
 come to the end of a part I can say it's the end and people can go out
 and I can send Jan Rynning out to bring in the other people. (Someone
 else says: “Janne, han trenger ingen mike” (translation: “Janne, he
 doesn't need a mike”)). Jan, are you prepared to go running out to
 fetch the other people? Jmr: I am looking for a microphone, and
 someone tells me it is inside this locked box. Rms: Now in the old
 days at the AI lab we would have taken a sledgehammer and cracked it
 open, and the broken door would be a lesson to whoever had dared to
 lock up something that people needed to use. Luckily however I used to
 study Bulgarian singing, so I have no trouble managing without a
 microphone.

 Anyway, should I set up this system to notify you about the parts of
 the talk, or do you just like to sit through all of it? (Answer:
 Yeaaah)

 When I started programming, it was 1969, and I did it in an IBM
 laboratory in New York. After that I went to a school with a computer
 science department that was probably like most of them. There were
 some professors that were in charge of what was supposed to be done,
 and there were people who decided who could use what. There was a
 shortage of terminals for most people, but a lot of the professors had
 terminals of their own in their offices, which was wasteful, but
 typical of their attitude. When I visited the Artificial Intelligence
 lab at MIT I found a spirit that was refreshingly different from that.
 For example: there, the terminals was thought of as belonging to
 everyone, and professors locked them up in their offices on pain of
 finding their doors broken down. I was actually shown a cart with a
 big block of iron on it, that had been used to break down the door of
 one professors office, when he had the gall to lock up a terminal.
 There were very few terminals in those days, there was probably
 something like five display terminals for the system, so if one of
 them was locked up, it was a considerable disaster.

 In the years that followed I was inspired by that ideas, and many
 times I would climb over ceilings or underneath floors to unlock rooms
 that had machines in them that people needed to use, and I would
 usually leave behind a note explaining to the people that they
 shouldn't be so selfish as to lock the door. The people who locked the
 door were basically considering only themselves. They had a reason of
 course, there was something they thought might get stolen and they
 wanted to lock it up, but they didn't care about the other people they
 were affecting by locking up other things in the same room. Almost
 every time this happened, once I brought it to their attention, that
 it was not up to them alone whether that room should be locked, they
 were able to find a compromise solution: some other place to put the
 things they were worried about, a desk they could lock, another little
 room. But the point is that people usually don't bother to think about
 that. They have the idea: “This room is Mine, I can lock it, to hell
 with everyone else”, and that is exactly the spirit that we must teach
 them not to have.

 But this spirit of unlocking doors wasn't an isolated thing, it was
 part of an entire way of life. The hackers at the AI lab were really
 enthusiastic about writing good programs, and interesting programs.
 And it was because they were so eager to get more work done, that they
 wouldn't put up with having the terminals locked up, or lots of other
 things that people could do to obstruct useful work. The 

Re: C interpreter in Lisp/scheme/python

2010-07-08 Thread Mark Tarver
On 14 June, 00:07, bolega gnuist...@gmail.com wrote:
 I am trying to compare LISP/Scheme/Python for their expressiveness.

 For this, I propose a vanilla C interpreter. I have seen a book which
 writes C interpreter in C.

 The criteria would be the small size and high readability of the code.

 Are there already answers anywhere ?

 How would a gury approach such a project ?

 Bolega

Probably you want to look at this thread

http://groups.google.co.uk/group/comp.lang.lisp/browse_frm/thread/7b1ab36f5d5cce0a/54afe11153025e27?hl=enlnk=gstq=minim#54afe11153025e27

where I specified a toy language Minim (much simpler than C) and the
goal was to construct an interpreter for it.  Similar problem.

Many solutions were given in different languages.  The thread is very
long.

One thing you might look at is whether some sort of lexer/parser is
supported in any of your targets.  Qi supports a compiler-compiler Qi-
YACC that allows you to write in BNF which makes this kind of project
much easier.

See

http://www.lambdassociates.org/Book/page404.htm

for an overview

Mark

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: the Python Foundation

2010-03-29 Thread Mark Tarver
On 24 Mar, 22:18, Steve Holden, Chairman, PSF chair...@python.org
wrote:
 MarkTarver wrote:
 From the website

  The Python Software Foundation (PSF) is a 501(c)(3) non-profit
  corporation that
  holds the intellectual property rights behind the Python programming
  language. We manage the open source licensing for Python version 2.1
  and later and own and protect the trademarks associated with Python.

  Could somebody explain 'what holding the intellectual property rights'
  means in this context and in what sense PSF manages the licensing and
  protects the trademarks associated with Python?   This is for my
  education.

 The PSF requires that contributors sign an agreement licensing their
 code to us, and allowing us to distribute it under the license of our
 choosing (this does not in any way preclude the contributor licensing
 the same code to any other party under different terms).

 In this way people who use Python can be relatively sure that the code
 is untrammeled by claims of copyright or patent by anyone other than the
 PSF, and can therefore use it without fear of losing their rights to do
 so because of legal action by third parties.

 We have also registered the trademark Python for use in reference to
 computer programming languages, thereby ensuring that we can take action
 should some ill-advised individual or organization decide to produce
 another language with Python in its name which we did not feel
 conformed sufficiently strictly to the language definition, for instance.

 The PSF has an established policy with regard to the use of its
 trademarks, which you can read at

  http://www.python.org/psf/trademarks/

 regards
  Steve
 --
 Steve Holden        Chairman, Python Software Foundation
 See PyCon Talks from Atlanta 2010  http://pycon.blip.tv/
 Holden Web LLC                http://www.holdenweb.com/
 UPCOMING EVENTS:        http://holdenweb.eventbrite.com/

Thankyou to all on this thread for this clarification.  I may return
and ask some questions if I need further clarification.

Mark
-- 
http://mail.python.org/mailman/listinfo/python-list


the Python Foundation

2010-03-24 Thread Mark Tarver
From the website

The Python Software Foundation (PSF) is a 501(c)(3) non-profit
corporation that
holds the intellectual property rights behind the Python programming
language. We manage the open source licensing for Python version 2.1
and later and own and protect the trademarks associated with Python.

Could somebody explain 'what holding the intellectual property rights'
means in this context and in what sense PSF manages the licensing and
protects the trademarks associated with Python?   This is for my
education.

thanks

Mark
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: strange python scripting error

2009-07-25 Thread Mark Tarver
On 24 July, 15:45, nn prueba...@latinmail.com wrote:
 On Jul 23, 7:03 pm, Dave Angel da...@ieee.org wrote:





  Mark Tarver wrote:
   I have a very strange error.  I have two test python files test.py and
   python.py which contain the following code

   #!/usr/bin/python
   print Content-type: text/html
   print
   print html
   print centerHello, Linux.com!/center
   print /html

   One file (test.py) works; you call it up and it shows a web page with

   Hello, Linux.com

   The other fails with a server configuration error.  Both are running
   under Linux, same server, same permissions.  Running a character scan
   shows that both files contain the same printable characters and are
   therefore typographically identical.   They are absolutely the same.

   The only hint at a difference I can see is that my ftp program says
   the files are of unequal lengths.  test.py is 129 bytes long.
   python.py 134 bytes long.

   A zipped folder containing both files is at

  www.lambdassociates.org/weird.zip

   Any ideas welcome.

   Mark

  Easiest explanation is that python.py has Windows-style newlines.  In
  other words, each line ends with 0d0a, rather than the Unix convention
  of 0a.

  If your server is Unix-based, it can't handle that first line, since it
  has an illegal character (0d) following the

  #!/usr/bin/python

  line.  Convert it to Unix line-endings.

  DaveA

 Use dos2unix for conversion of the longer file and try again:

 http://linux.about.com/od/commands/l/blcmdl1_dos2uni.htm- Hide quoted text -

 - Show quoted text -

That sounds the ticket - but is there anything that runs under Windows
to do the trick?

Mark
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: strange python scripting error

2009-07-25 Thread Mark Tarver
On 25 July, 10:30, Mark Tarver dr.mtar...@ukonline.co.uk wrote:
 On 24 July, 15:45, nn prueba...@latinmail.com wrote:





  On Jul 23, 7:03 pm, Dave Angel da...@ieee.org wrote:

   Mark Tarver wrote:
I have a very strange error.  I have two test python files test.py and
python.py which contain the following code

#!/usr/bin/python
print Content-type: text/html
print
print html
print centerHello, Linux.com!/center
print /html

One file (test.py) works; you call it up and it shows a web page with

Hello, Linux.com

The other fails with a server configuration error.  Both are running
under Linux, same server, same permissions.  Running a character scan
shows that both files contain the same printable characters and are
therefore typographically identical.   They are absolutely the same.

The only hint at a difference I can see is that my ftp program says
the files are of unequal lengths.  test.py is 129 bytes long.
python.py 134 bytes long.

A zipped folder containing both files is at

   www.lambdassociates.org/weird.zip

Any ideas welcome.

Mark

   Easiest explanation is that python.py has Windows-style newlines.  In
   other words, each line ends with 0d0a, rather than the Unix convention
   of 0a.

   If your server is Unix-based, it can't handle that first line, since it
   has an illegal character (0d) following the

   #!/usr/bin/python

   line.  Convert it to Unix line-endings.

   DaveA

  Use dos2unix for conversion of the longer file and try again:

 http://linux.about.com/od/commands/l/blcmdl1_dos2uni.htm-Hide quoted text -

  - Show quoted text -

 That sounds the ticket - but is there anything that runs under Windows
 to do the trick?

 Mark- Hide quoted text -

 - Show quoted text -

OK, got a version

http://www.bastet.com/

has dos2unix.exe for Windows.  And it solves the problem.

Many thanks all for help on this baffling error

Mark
-- 
http://mail.python.org/mailman/listinfo/python-list


strange python scripting error

2009-07-23 Thread Mark Tarver
I have a very strange error.  I have two test python files test.py and
python.py which contain the following code

#!/usr/bin/python
print Content-type: text/html
print
print html
print centerHello, Linux.com!/center
print /html

One file (test.py) works; you call it up and it shows a web page with

Hello, Linux.com

The other fails with a server configuration error.  Both are running
under Linux, same server, same permissions.  Running a character scan
shows that both files contain the same printable characters and are
therefore typographically identical.   They are absolutely the same.

The only hint at a difference I can see is that my ftp program says
the files are of unequal lengths.  test.py is 129 bytes long.
python.py 134 bytes long.

A zipped folder containing both files is at

www.lambdassociates.org/weird.zip

Any ideas welcome.

Mark
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: strange python scripting error

2009-07-23 Thread Mark Tarver
On 23 July, 18:01, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
 On Thu, 23 Jul 2009 08:48:46 -0700 (PDT), Mark Tarver
 dr.mtar...@ukonline.co.uk declaimed the following in
 gmane.comp.python.general:

  I have a very strange error.  I have two test python files test.py and
  python.py which contain the following code

         snip

  The other fails with a server configuration error.  Both are running

         Way out from left field... Have you tried renaming python.py to
 some other name?

         If the server is configured to treat .py as executable files, it
 might be getting confused over python.py trying to invoke python.
 --
         Wulfraed        Dennis Lee Bieber               KD6MOG
         wlfr...@ix.netcom.com             wulfr...@bestiaria.com
                 HTTP://wlfraed.home.netcom.com/
         (Bestiaria Support Staff:               web-a...@bestiaria.com)
                 HTTP://www.bestiaria.com/

Yes; tried pyth.py - still failed.

Mark
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: strange python scripting error

2009-07-23 Thread Mark Tarver
On 23 July, 18:01, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
 On Thu, 23 Jul 2009 08:48:46 -0700 (PDT), Mark Tarver
 dr.mtar...@ukonline.co.uk declaimed the following in
 gmane.comp.python.general:

  The only hint at a difference I can see is that my ftp program says
  the files are of unequal lengths.  test.py is 129 bytes long.
  python.py 134 bytes long.

         Just a guess...

         Line endings... lf vs crlf

 --
         Wulfraed        Dennis Lee Bieber               KD6MOG
         wlfr...@ix.netcom.com             wulfr...@bestiaria.com
                 HTTP://wlfraed.home.netcom.com/
         (Bestiaria Support Staff:               web-a...@bestiaria.com)
                 HTTP://www.bestiaria.com/

Is that linefeed + ctrl or what?  I can't pick up any difference
reading the files char by char in Lisp.  How do you find the
difference?

Mark
-- 
http://mail.python.org/mailman/listinfo/python-list


scripting and uploading in Python

2009-05-26 Thread Mark Tarver
I've recently purchased a site on a Linux server which runs Python.

Generally I'd like to bring myself up to speed on scripting in
Python.   Any good reads - dead tree or otherwise?

One thing I need to learn is to be able to give folks the power to
upload files onto their own disk space using passwords.

thanks

Mark
-- 
http://mail.python.org/mailman/listinfo/python-list


unbinding a global variable in Python

2009-04-30 Thread Mark Tarver
In Lisp this is done so

 (setq *g* 0)
0

 *g*
0

 (makunbound '*g*)
*g*

 *g*
error: unbound variable

How is this done in Python?

Mark

--
http://mail.python.org/mailman/listinfo/python-list


Re: unbinding a global variable in Python

2009-04-30 Thread Mark Tarver
On 30 Apr, 12:36, Diez B. Roggisch de...@nospam.web.de wrote:
 Mark Tarver wrote:
  In Lisp this is done so

  (setq *g* 0)
  0

  *g*
  0

  (makunbound '*g*)
  *g*

  *g*
  error: unbound variable

  How is this done in Python?

  Mark
  foo = bar
  del foo
  foo

 Traceback (most recent call last):
   File stdin, line 1, in module
 NameError: name 'foo' is not defined



 Be aware of functions that declare global variables though:

  def foo():

 ...     global bar
 ...     bar = 10
 ... foo()
  bar
 10
  del bar
  bar

 Traceback (most recent call last):
   File stdin, line 1, in module
 NameError: name 'bar' is not defined foo()
  bar

 10

 Diez- Hide quoted text -

 - Show quoted text -

Great; and how can I test to see if a global is bound?

e.g Lisp

 (setq *g* 0)
0

 (boundp '*g*)
t

Mark
--
http://mail.python.org/mailman/listinfo/python-list


how to coerce to a string in Python?

2009-04-28 Thread Mark Tarver
How do you coerce an object to a string in Python?

123 -- 1 2 3
[1,2,3] - [1,2,3] etc

Mark
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to coerce to a string in Python?

2009-04-28 Thread Mark Tarver
On 28 Apr, 19:58, Mark Tarver dr.mtar...@ukonline.co.uk wrote:
 How do you coerce an object to a string in Python?

 123 -- 1 2 3
 [1,2,3] - [1,2,3] etc

 Mark

Ah , 'str' a pure guess but it worked.

Mark

--
http://mail.python.org/mailman/listinfo/python-list


Re: python list handling and Lisp list handling

2009-04-25 Thread Mark Tarver
On 25 Apr, 05:01, Carl Banks pavlovevide...@gmail.com wrote:
 On Apr 24, 8:19 am, Mark Tarver dr.mtar...@ukonline.co.uk wrote:





  This page says that Python lists are often flexible arrays

 http://www.brpreiss.com/books/opus7/html/page82.html

  but also says that their representation is implementation dependent.
  As far as I see this should mean that element access in Python should
  run in constant time.  Now if so this is a boon, because generally

  'A list is a sequence of elements, but it is not a single primitive
  object; it is made of cons cells, one cell per element. Finding the
  nth element requires looking through n cons cells, so elements farther
  from the beginning of the list take longer to access. But it is
  possible to add elements to the list, or remove elements.'

  (fromhttp://www.chemie.fu-berlin.de/chemnet/use/info/elisp/elisp_7.html)

  But are Python lists also indistinguishable from conventional
  Lisplists for list processing.  For example, can I modify a Python
  list non-destructively?  Are they equivalent to Lisp lists. Can CAR
  and CDR in Lisp be thought of as

  def car (x):
    return x[0]

  def cdr (x):
    return x[1:]

  The idea of a list in which elements can be accessed in constant time
  is novel to me.

 That's because Python lists aren't lists.

 It might be an interesting exercise to compare Python lists and Lisp
 lists, but you should do it under the understanding that they are not
 analogous types.  (A Python list is analogous to a Lisp vector.)  The
 two objects have almost no similarity in typical their manner of use;
 even the way you iterate through them is different.

 You could, as you've tried to do here, operate on Python lists the
 same way you operate on Lisp lists, but you'd just be doing things the
 hard way.  Whatever you're trying to do with cons, car, and cdr,
 chances are Python has a high-level way to do it built in that
 performs a lot better.

 Then again, Lispers seem to like to reimplement high-level operations
 from low-level primitives every time they need it.  So if you liked
 doing that you might not mind doing a lot of extra work using your
 homebrew cons, car, and cdr.

 Carl Banks- Hide quoted text -

 - Show quoted text -

OK; I guess the answer to the question

Assuming the following Python encodings, and ignoring questions
of performance, would Python and Lisp lists then be observationally
indistinguishable? i.e. would these then be fair encodings?

is a 'yes'.   Any disagreement?

Mark
--
http://mail.python.org/mailman/listinfo/python-list


Re: python list handling and Lisp list handling

2009-04-25 Thread Mark Tarver
What is different is the concept of all globals that
 reference G.  For example:

  a = [1, 2, 3]
  b = a
  a[0] = 0
  print b

 [0, 2, 3]

I see that Python had an id too ;).

Mark
--
http://mail.python.org/mailman/listinfo/python-list


python list handling and Lisp list handling

2009-04-24 Thread Mark Tarver
This page says that Python lists are often flexible arrays

http://www.brpreiss.com/books/opus7/html/page82.html

but also says that their representation is implementation dependent.
As far as I see this should mean that element access in Python should
run in constant time.  Now if so this is a boon, because generally

'A list is a sequence of elements, but it is not a single primitive
object; it is made of cons cells, one cell per element. Finding the
nth element requires looking through n cons cells, so elements farther
from the beginning of the list take longer to access. But it is
possible to add elements to the list, or remove elements.'

(from http://www.chemie.fu-berlin.de/chemnet/use/info/elisp/elisp_7.html)

But are Python lists also indistinguishable from conventional
Lisplists for list processing.  For example, can I modify a Python
list non-destructively?  Are they equivalent to Lisp lists. Can CAR
and CDR in Lisp be thought of as

def car (x):
  return x[0]

def cdr (x):
  return x[1:]

The idea of a list in which elements can be accessed in constant time
is novel to me.

Mark
--
http://mail.python.org/mailman/listinfo/python-list


Re: python list handling and Lisp list handling

2009-04-24 Thread Mark Tarver
On 24 Apr, 17:19, Paul Rubin http://phr...@nospam.invalid wrote:
 Mark Tarver dr.mtar...@ukonline.co.uk writes:
  But are Python lists also indistinguishable from conventional
  Lisplists for list processing.  

 Forgot to add: you might look athttp://norvig.com/python-lisp.html

 Mark Tarver dr.mtar...@ukonline.co.uk writes:
  But are Python lists also indistinguishable from conventional
  Lisplists for list processing.

 They are very different.  There is nothing like cons or nconc.
 You can't convert two lists to a single longer list with nconc,
 etc.

Ah;  so this

def cons (x,y):
  return [x] + y

is not accurate?

Mark
--
http://mail.python.org/mailman/listinfo/python-list


Re: python list handling and Lisp list handling

2009-04-24 Thread Mark Tarver
On 24 Apr, 19:54, Arnaud Delobelle arno...@googlemail.com wrote:
 Mark Tarver dr.mtar...@ukonline.co.uk writes:
  Ah;  so this

  def cons (x,y):
    return [x] + y

  is not accurate?

 Depends what you mean by accurate!

 in lisp, if you do:

     (setq a '(1 2))
     (setq b (cons 0 a))
     (rplaca a 3)

 Then
     a is now (3 2)
     b is now (0 3 2)

 In Python, if you do:

     a = [1, 2]
     b = cons(0, a) # with your definition of cons
     a[0] = 3

 Then
     a is now [3, 2]
     b is now [0, 1, 2]

 So in this respect, it is not accurate.  But that's because Python lists
 are vectors not conses.

 --
 Arnaud

Thanks for that.

OK; I think I get it.  RPLACA and RPLACD are part of the id of Common
Lisp which I rarely contemplate.  However what it seems to be is that
the difference is this. Lisp operates a destructive operation like
RPLACA in such a way that RPLACA on a global G not only changes G, but
all globals that reference G.  Python on the other hand has a
destructive operation a[0] =  which acts a bit like RPLACA but
whose change is local to the global changed.  I take it that this is
because Python essentially copies the list, creating a brand new
vector rather than playing with pointers.  Is that more or less it?

Which brings me to my next question.  Assuming that we ban the use of
destructive operations like a[0] = ... Lisp's RPLACA and all the
rest.  Assuming the following Python encodings, and ignoring questions
of performance, would Python and Lisp lists then be observationally
indistinguishable? i.e. would these then be fair encodings?

def car (x):
  return x[0]

def cdr (x):
  return x[1:]

def cons (x,y):
  return [x] + y

Mark
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-06-08 Thread Mark Tarver
On 22 May, 17:14, cm_gui [EMAIL PROTECTED] wrote:
 Python is slow.    Almost all of the web applications written in
 Python are slow.   Zope/Plone is slow, sloow, so very slooow.  Even
 Google Apps is not faster.   Neither is Youtube.
 Facebook and Wikipedia (Mediawiki), written in PHP, are so much faster
 than Python.
 Okay, they probably use caching or some code compilation -- but Google
 Apps and those Zope sites probably also use caching.

 I've yet to see a web application written in Python which is really
 fast.

You might like to look at Norvig's analysis which supports your view
about Python being slow.

http://norvig.com/python-lisp.html

Mark

--
http://mail.python.org/mailman/listinfo/python-list


Lisp for the C21

2007-05-04 Thread Mark Tarver
QUOTE
Python has readable syntax, a huge library, and bindings for what
seems like every major in linux. Perl has CPAN. It seems with those
languages if you want to do something all you have to do is import
functionality from a library someone had written and use that.

In lisp you'd have to roll your own.

Why should I keep on learning lisp when there are python and perl?
UNQUOTE

I can see where this guy is coming from (though I can't find the
original post any more (?)).

See my remarks on the Lisp for the Twenty First Century

http://www.lambdassociates.org/lC21.htm

for our take on this one.

Mark


-- 
http://mail.python.org/mailman/listinfo/python-list


merits of Lisp vs Python

2006-12-08 Thread Mark Tarver
How do you compare Python to Lisp?  What specific advantages do you
think that one has over the other?

Note I'm not a Python person and I have no axes to grind here.  This is
just a question for my general education.

Mark

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: merits of Lisp vs Python

2006-12-08 Thread Mark Tarver

Paul Rubin wrote:
 Mark Tarver [EMAIL PROTECTED] writes:
  How do you compare Python to Lisp?  What specific advantages do you
  think that one has over the other?

http://google.com/search?q=python+lispbtnI=I'm+feeling+lucky

Thanks;  a quick read of your reference to Norvig's analysis

http://norvig.com/python-lisp.html

seems to show that Python is a cut down (no macros) version of Lisp
with a worse performance.  The only substantial advantage I can see is
that GUI, and Web libraries are standard.  This confirms my suspicion
that Lisp is losing out to newbies because of its
lack of standard support for the things many people want to do.

Mark

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: merits of Lisp vs Python

2006-12-08 Thread Mark Tarver
Bill Atkins wrote:
 Mark Tarver [EMAIL PROTECTED] writes:

  How do you compare Python to Lisp?  What specific advantages do you
  think that one has over the other?
 
  Note I'm not a Python person and I have no axes to grind here.  This is
  just a question for my general education.
 
  Mark

 What was the reasoning behind cross-posting this to c.l.p and c.l.l?
 This type of question inevitably leads to controversy.

I don't mind controversy - as long as there is intelligent argument.
And since it involves Python and Lisp, well it should be posted to both
groups.   The Lispers will tend to say that Lisp is better for sure -
so it gives the Python people a chance to defend this creation.

I'm looking at Python and I see that the syntax would appeal to a
newbie.  Its clearer than ML which is a mess syntactically.  But I
don't see where the action is in Python.   Not yet anyway.  Lisp syntax
is easy to learn.  And giving up an order of magnitude is a high price
to pay for using it over Lisp.

Mark

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: merits of Lisp vs Python

2006-12-08 Thread Mark Tarver
Kaz Kylheku wrote:
 Mark Tarver wrote:
  I don't mind controversy - as long as there is intelligent argument.
  And since it involves Python and Lisp, well it should be posted to both
  groups.   The Lispers will tend to say that Lisp is better for sure -
  so it gives the Python people a chance to defend this creation.

 And that would be our confirmation that this is another trolling
 asshole.

This would be a confirmation that you are ignorant in your manners and
don't know how to address a straight question.  

Mark

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-20 Thread Mark Tarver
Hi,

You wrote into the Qilang News group with your problem.
This is a solution in 17 lines of Qi for any n-product = 2.
It falls short of your complete requirement since it uses
generate and then test, rather than interleaving the
two.

(define challenge
   Patterns N X - (filter (/. Y (member Y Patterns)) (n-product N X)))

(define n-product
2 X - (cartesian-product l X X)
N X - (cartesian-product c X (n-product (- N 1) X)))

(define cartesian-product
   _ [ ] _ - [ ]
   c [X | Y] Z - (append (map (/. W [X | W]) Z) (cartesian-product c Y
Z))
   l  [X | Y] Z - (append (map (/. W [X W]) Z) (cartesian-product l Y
Z)))

(define filter
_ [] - []
F [X | Y] - (filter F Y)   where (F X)
F [X | Y] - [X | (filter F Y)])

(define member
_ [] - false
X [Pattern | _]  - truewhere (query-prolog [[= Pattern X]])
X [_ | Patterns] - (member X Patterns))

Notes:

Pattern filtering is done by a unification test within the member
function.  You
can do this most easily by calling Qi Prolog using query-prolog.
Here's a test.

(42 -) (n-product 3 [a b c])
[[a a a] [a a b] [a a c] [a b a] [a b b] [a b c] [a c a] [a c b] [a c
c]
 [b a a] [b a b] [b a c] [b b a] [b b b] [b b c] [b c a] [b c b] [b c
c]
 [c a a] [c a b] [c a c] [c b a] [c b b] [c b c] [c c a] [c c b] [c c
c]]

OK, remove all lists beginning [a a ].

(43-) (challenge [[a a | X]] 3 [a b c])
[[a b a] [a b b] [a b c] [a c a] [a c b] [a c c] [b a a] [b a b] [b a
c]
 [b b a] [b b b] [b b c] [b c a] [b c b] [b c c] [c a a] [c a b] [c a
c]
 [c b a] [c b b] [c b c] [c c a] [c c b] [c c c]]

Remove all lists beginning with a or b.

(51-) (challenge [[a | X] [b | X]] 3 [a b c])
[[c a a] [c a b] [c a c] [c b a] [c b b] [c b c] [c c a] [c c b] [c c
c]]

Mark

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-20 Thread Mark Tarver
Interesting.  But you probably need to post this as a new
message, since it is a distinctly different
problem from the one driving this thread.

Mark

-- 
http://mail.python.org/mailman/listinfo/python-list