Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
a golden oldie challenge: Eliza
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 41 of 41 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Stevan Apter  
View profile   Translate to Translated (View Original)
 More options 24 Feb 2008, 15:49
Newsgroups: comp.lang.lisp, comp.lang.functional
From: "Stevan Apter" <encryptednos...@nsl.com>
Date: Sun, 24 Feb 2008 10:49:22 -0500
Local: Sun 24 Feb 2008 15:49
Subject: Re: a golden oldie challenge: Eliza
i'd rather say:  "programs (in L) should be readable by people (who know L)."  i have no idea how
to determine absolute readability (except to require that the font-size be within a certain range.)

"Dimitre Liotev" <no...@email.com> wrote in message news:_qqdnckGTcUDG1zanZ2dnUVZ_hSdnZ2d@giganews.com...
Mark Tarver <dr.mtar...@ukonline.co.uk> writes:
> Sorry I missed a couple of later attempts

> Lisp 150 LOC ................ Peter Norvig
> Qi (slightly revised) 63 LOC .................Mark Tarver
> Ruby 53 LOC .................William James
> Q 10 LOC ..................Steven Apter
> K 3 LOC ...................Steven Apter
> Ruby (again)            17 LOC ...................William James
> Mathematica            20 LOC .................. Szabolcs

> Mark

So K wins the competition in brevity, but does the ability to squeeze
code into illegible character blobs say anything about the suitability
of a programming language for writing readable and understandable
programs? I'd rather follow the principle that "Programs must be written
for people to read, and only incidentally for machines to execute."...

--
Dimitre Liotev
(format t "~{~a~}" (reverse '("et" "n" "in." "a" "zn" "@" "l" "d")))


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stevan Apter  
View profile   Translate to Translated (View Original)
 More options 24 Feb 2008, 15:56
Newsgroups: comp.lang.lisp, comp.lang.functional
From: "Stevan Apter" <encryptednos...@nsl.com>
Date: Sun, 24 Feb 2008 10:56:28 -0500
Local: Sun 24 Feb 2008 15:56
Subject: Re: a golden oldie challenge: Eliza

both the k and the q program use P.  did mark have this feature in his
Qi version?

>> a few observations:

>> the 'i' function gives you prompt-and-respond in the console by
>> call 'e' until the user gives no prompt:

>> i:{while[count r:read0 0;-1"? ",e r;]}

> I was talking about the K program; you're talking about the Q program.

activate the k script with:  while[#r:0:0;-1"? ",e r]

>> the 'P' function maps first- and second-person:

>> P:{(y,x,z)(x,y)?z}.`$(("you";"your";"yourself";"i'm";"i am");("i";"my";"myself";"you are";"you're"))

> So this will change "your" to "my".  Will it, like the Ruby program,
> change "my" to "your"?

yes, as should be obvious by inspecting the sample i/o above.

>> instead of rotating multiple-responses, the k version picks a
>> response randomly from the set.  this is less predictable than
>> rotation.

> That has the defect of possibly repeating the same response
> immediately instead of cycling through all of the responses
> before repeating.

unlike humans, who never repeat themselves.  :-)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dimitre Liotev  
View profile   Translate to Translated (View Original)
 More options 24 Feb 2008, 16:18
Newsgroups: comp.lang.lisp, comp.lang.functional
From: Dimitre Liotev <no...@email.com>
Date: Sun, 24 Feb 2008 11:18:27 -0500
Local: Sun 24 Feb 2008 16:18
Subject: Re: a golden oldie challenge: Eliza

William James <w_a_x_...@yahoo.com> writes:
> This does so little that it should be no more than 2 lines.
> In Ruby:

> S =
>   [ /father|mother|brother|sister/i, "Tell me about your 0."],
>   [ /\b(am|i'm) (.*)/i, ["Why are you 2?","Have you always been 2?"]],
>   [ /\bI was (.*)/i, ["Why were you 1?","I can't believe you were

[...]

He, Ruby is so verbose, both K an Q beat it to death when it comes to
brevity. Witness the power, a sudoku solver in K:

f:{$[&/x;,x;,/f'@[x;i;:;]'&27=x[,/p i:x?0]?!10]}

Not that I understand what this eyesore means, but according to this
blog it is supposed to be a sudoku solver:

http://www.wagerlabs.com/blog/2008/02/shortest-sudoku.html

Time to abandon Ruby and move to K?

--
Dimitre Liotev
(format t "~{~a~}" (reverse '("et" "n" "in." "a" "zn" "@" "l" "d")))


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Arved Sandstrom  
View profile   Translate to Translated (View Original)
 More options 24 Feb 2008, 17:28
Newsgroups: comp.lang.lisp, comp.lang.functional
From: Arved Sandstrom <asandstrom...@eastlink.ca>
Date: Sun, 24 Feb 2008 17:28:25 GMT
Local: Sun 24 Feb 2008 17:28
Subject: Re: a golden oldie challenge: Eliza

Stevan Apter wrote:
> i'd rather say:  "programs (in L) should be readable by people (who know
> L)."  i have no idea how to determine absolute readability (except to
> require that the font-size be within a certain range.)

This fellow (http://www.perlmonks.org/?node_id=592616) has some thoughts on
absolute readability. I think it's a sensible article.

AHS
--
* change 'two' to '2' to email me


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rainer Joswig  
View profile   Translate to Translated (View Original)
 More options 24 Feb 2008, 17:29
Newsgroups: comp.lang.lisp, comp.lang.functional
From: Rainer Joswig <jos...@lisp.de>
Date: Sun, 24 Feb 2008 18:29:12 +0100
Local: Sun 24 Feb 2008 17:29
Subject: Re: a golden oldie challenge: Eliza
In article
<d27c55f3-4ee0-41a6-9974-8009d818c...@t66g2000hsf.googlegroups.com>,
 Mark Tarver <dr.mtar...@ukonline.co.uk> wrote:

Below is the Common Lisp version from Norvig.

I have removed the duplicated definitions from his code.
He is developing the code in his book (especially the pattern
matcher), so he has more than one version of several functions.
The code is also written in a very readable style,
to support the educational purpose of his book.

When the comments and the rules are removed, the code
is about 110 lines.

;;; ==============================

;;; -*- Mode: Lisp; Syntax: Common-Lisp; -*-
;;; Code from Paradigms of Artificial Intelligence Programming
;;; Copyright (c) 1991 Peter Norvig

(defun starts-with (list x)
  "Is x a list whose first element is x?"
  (and (consp list) (eql (first list) x)))

(defun flatten (the-list)
  "Append together elements (or lists) in the list."
  (mappend #'mklist the-list))

(defun mklist (x)
  "Return x if it is a list, otherwise (x)."
  (if (listp x)
      x
      (list x)))

(defun mappend (fn the-list)  
  "Apply fn to each element of list and append the results."
  (apply #'append (mapcar fn the-list)))

(defun random-elt (choices)
  "Choose an element from a list at random."
  (elt choices (random (length choices))))

(defun variable-p (x)
  "Is x a variable (a symbol beginning with `?')?"
  (and (symbolp x) (equal (char (symbol-name x) 0) #\?)))

(defconstant fail nil "Indicates pat-match failure")

(defconstant no-bindings '((t . t))
  "Indicates pat-match success, with no variables.")

(defun get-binding (var bindings)
  "Find a (variable . value) pair in a binding list."
  (assoc var bindings))

(defun binding-val (binding)
  "Get the value part of a single binding."
  (cdr binding))

(defun lookup (var bindings)
  "Get the value part (for var) from a binding list."
  (binding-val (get-binding var bindings)))

(defun match-variable (var input bindings)
  "Does VAR match input?  Uses (or updates) and returns bindings."
  (let ((binding (get-binding var bindings)))
    (cond ((not binding) (extend-bindings var input bindings))
          ((equal input (binding-val binding)) bindings)
          (t fail))))

(defun extend-bindings (var val bindings)
  "Add a (var . value) pair to a binding list."
  (cons (cons var val)
        ;; Once we add a "real" binding,
        ;; we can get rid of the dummy no-bindings
        (if (and (eq bindings no-bindings))
            nil
            bindings)))

(defun pat-match (pattern input &optional (bindings no-bindings))
  "Match pattern against input in the context of the bindings"
  (cond ((eq bindings fail) fail)
        ((variable-p pattern)
         (match-variable pattern input bindings))
        ((eql pattern input) bindings)
        ((segment-pattern-p pattern)
         (segment-match pattern input bindings))
        ((and (consp pattern) (consp input))
         (pat-match (rest pattern) (rest input)
                    (pat-match (first pattern) (first input)
                               bindings)))
        (t fail)))

(defun segment-pattern-p (pattern)
  "Is this a segment matching pattern: ((?* var) . pat)"
  (and (consp pattern)
       (starts-with (first pattern) '?*)))

(defun segment-match (pattern input bindings &optional (start 0))
  "Match the segment pattern ((?* var) . pat) against input."
  (let ((var (second (first pattern)))
        (pat (rest pattern)))
    (if (null pat)
        (match-variable var input bindings)
        ;; We assume that pat starts with a constant
        ;; In other words, a pattern can't have 2 consecutive vars
        (let ((pos (position (first pat) input
                             :start start :test #'equal)))
          (if (null pos)
              fail
              (let ((b2 (pat-match
                          pat (subseq input pos)
                          (match-variable var (subseq input 0 pos)
                                          bindings))))
                ;; If this match failed, try another longer one
                (if (eq b2 fail)
                    (segment-match pattern input bindings (+ pos 1))
                    b2)))))))

(defun rule-pattern (rule) (first rule))
(defun rule-responses (rule) (rest rule))

(defun use-eliza-rules (input)
  "Find some rule with which to transform the input."
  (some #'(lambda (rule)
            (let ((result (pat-match (rule-pattern rule) input)))
              (if (not (eq result fail))
                  (sublis (switch-viewpoint result)
                          (random-elt (rule-responses rule))))))
        *eliza-rules*))

(defun switch-viewpoint (words)
  "Change I to you and vice versa, and so on."
  (sublis '((I . you) (you . I) (me . you) (am . are))
          words))

(defun read-line-no-punct ()
  "Read an input line, ignoring punctuation."
  (read-from-string
    (concatenate 'string "(" (substitute-if #\space #'punctuation-p
                                            (read-line))
                 ")")))

(defun punctuation-p (char) (find char ".,;:`!?#-()\\\""))

(defun print-with-spaces (list)
  (format t "~{~a ~}" list))

(defun eliza ()
  "Respond to user input using pattern matching rules."
  (loop
    (print 'eliza>)
    (let* ((input (read-line-no-punct))
           (response (flatten (use-eliza-rules input))))
      (print-with-spaces response)
      (if (equal response '(good bye)) (RETURN)))))

(defparameter *eliza-rules*
 '((((?* ?x) hello (?* ?y))      
    (How do you do.  Please state your problem.))
   (((?* ?x) I want (?* ?y))    
    (What would it mean if you got ?y)
    (Why do you want ?y) (Suppose you got ?y soon))
   (((?* ?x) if (?* ?y))
    (Do you really think its likely that ?y) (Do you wish that ?y)
    (What do you think about ?y) (Really-- if ?y))
   (((?* ?x) no (?* ?y))
    (Why not?) (You are being a bit negative)
    (Are you saying "NO" just to be negative?))
   (((?* ?x) I was (?* ?y))      
    (Were you really?) (Perhaps I already knew you were ?y)
    (Why do you tell me you were ?y now?))
   (((?* ?x) I feel (?* ?y))    
    (Do you often feel ?y ?))
   (((?* ?x) I felt (?* ?y))    
    (What other feelings do you have?))))

;;; ==============================


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stevan Apter  
View profile   Translate to Translated (View Original)
 More options 24 Feb 2008, 18:03
Newsgroups: comp.lang.lisp, comp.lang.functional
From: "Stevan Apter" <encryptednos...@nsl.com>
Date: Sun, 24 Feb 2008 13:03:11 -0500
Local: Sun 24 Feb 2008 18:03
Subject: Re: a golden oldie challenge: Eliza

"Arved Sandstrom" <asandstrom...@eastlink.ca> wrote in message news:ZOhwj.38548$FO1.4192@edtnps82...
> Stevan Apter wrote:

>> i'd rather say:  "programs (in L) should be readable by people (who know
>> L)."  i have no idea how to determine absolute readability (except to
>> require that the font-size be within a certain range.)

> This fellow (http://www.perlmonks.org/?node_id=592616) has some thoughts on
> absolute readability. I think it's a sensible article.

thanks.

languages make different trade-offs.  i was once asked to write a style-manual
for programmers new to k.  this is the result:  www.nsl.com/papers/style.pdf.

eliza.q mostly follows the rules.  eliza.k breaks them all!

now, if you want to see some gorgeous C code ... http://nsl.com/papers/origins.htm.

:-)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Neelakantan Krishnaswami  
View profile   Translate to Translated (View Original)
 More options 24 Feb 2008, 18:03
Newsgroups: comp.lang.lisp, comp.lang.functional
Follow-up To: comp.lang.functional
From: Neelakantan Krishnaswami <ne...@cs.cmu.edu>
Date: Sun, 24 Feb 2008 18:03:20 +0000 (UTC)
Local: Sun 24 Feb 2008 18:03
Subject: Re: a golden oldie challenge: Eliza
In article
<<d27c55f3-4ee0-41a6-9974-8009d818c...@t66g2000hsf.googlegroups.com>>,

Mark Tarver <dr.mtar...@ukonline.co.uk> wrote:
>> e:{$[(#b)=i:(|/'b:(w@:&~(w:(`$" "\:x@&~x in".?"))in`)in\:/:A)?1b;E@*1?#E
>>      " "~n:c@*,/(c:{x@*1?#x}C i)ss/:N;c
>>      .q.ssr[c;n;" "/:$(),P'(w[k],p:1_'(0,1+k:b[i]?1b)_`,w)"I"$n]]}

> Wow, looks like APL - also famous for inscrutable 1 liners.

J and K are descendants of APL that use ASCII as their character set.

--
Neel R. Krishnaswami
ne...@cs.cmu.edu


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ken Tilton  
View profile   Translate to Translated (View Original)
 More options 24 Feb 2008, 18:59
Newsgroups: comp.lang.lisp, comp.lang.functional
From: Ken Tilton <kennytil...@optonline.net>
Date: Sun, 24 Feb 2008 13:59:55 -0500
Local: Sun 24 Feb 2008 18:59
Subject: Re: a golden oldie challenge: Eliza

Looks familiar. We may have met briefly if you were in that office on
the 30th floor at UBS with the Special K carton outside. I wandered in
one day, ended up talking about GC with the K crew, got a free style
guide and K manual for my trouble. Might still have it somewhere.

I was a per diem guy so did not get the K training. :(

kenny

--
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/

"In the morning, hear the Way;
  in the evening, die content!"
                     -- Confucius


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William James  
View profile   Translate to Translated (View Original)
 More options 24 Feb 2008, 20:36
Newsgroups: comp.lang.lisp, comp.lang.functional
From: William James <w_a_x_...@yahoo.com>
Date: Sun, 24 Feb 2008 12:36:12 -0800 (PST)
Local: Sun 24 Feb 2008 20:36
Subject: Re: a golden oldie challenge: Eliza
On Feb 24, 9:56 am, "Stevan Apter" <encryptednos...@nsl.com> wrote:

So what you posted as the k program was not the complete
k program.

>     did mark have this feature in his
> Qi version?

No.

> >> a few observations:

> >> the 'i' function gives you prompt-and-respond in the console by
> >> call 'e' until the user gives no prompt:

> >> i:{while[count r:read0 0;-1"? ",e r;]}

So what you posted as the k program was not the complete
k program.

Mark Tarver was led to believe that the complete program
was 3 lines.

Perhaps the complete k program would be something like

P:{(y,x,z)(x,y)?z}[`$("you";"your";"yourself";"i'm";"i am");`$
("i";"my";"myself";"you are";"you're")]

e:{$[(#b)=i:(|/'b:(w@:&~(w:(`$" "\:x@&~x in".?"))in`)in\:/:A)?1b;E@*1?
#E
     " "~n:c@*,/(c:{x@*1?#x}C i)ss/:N;c
     .q.ssr[c;n;" "/:$(),P'(w[k],p:1_'(0,1+k:b[i]?1b)_`,w)"I"$n]]}

i:{while[count r:read0 0;-1"? ",e r;]}

> >> instead of rotating multiple-responses, the k version picks a
> >> response randomly from the set.  this is less predictable than
> >> rotation.

> > That has the defect of possibly repeating the same response
> > immediately instead of cycling through all of the responses
> > before repeating.

> unlike humans, who never repeat themselves.  :-)

The purpose of having multiple replies is to put off
repetition as long as possible.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William James  
View profile   Translate to Translated (View Original)
 More options 24 Feb 2008, 21:11
Newsgroups: comp.lang.lisp, comp.lang.functional
From: William James <w_a_x_...@yahoo.com>
Date: Sun, 24 Feb 2008 13:11:47 -0800 (PST)
Local: Sun 24 Feb 2008 21:11
Subject: Re: a golden oldie challenge: Eliza
On Feb 22, 5:49 am, Mark Tarver <dr.mtar...@ukonline.co.uk> wrote:

Unlike my 2-line Ruby version, this one changes first-person
pronouns to second-person, and vice versa.

S =
  [ /father|mother|brother|sister/i, "Tell me about your 0."],
  [ /\b(am|i'm) (.*)/i, ["Why are you 2?","Have you always been 2?"]],
  [ /\bI was (.*)/i, ["Why were you 1?","I can't believe you were
1."]],
  [ /\bI will (.*)/i, "Do you think it's wise to 1?"],
  [ /\bI (.*)/i, "Why do you 1?" ],
  [ /\b(you|your|yours)\b/i, ["We're talking about you, not me.",
             "Please don't be so personal."]],
  [ /.*/, ["That's very interesting. Do go on.",
        "Tell me more.",
        "I'm not sure that I understand you fully.",
        "Can you elaborate on that?" ]]

P=Hash[*"I|you|my|your|myself|yourself|you are|I am|you're|I
am".split('|')]
(gets;sub(/[.!?,; ]+$/,"");x=Array(S.find{|a|$m=$_.match(a[0])}[1])
puts x[rand(x.size)].gsub(/\d/){$m.to_a[$&.to_i].
scan(/you are|you're|\w+|\W+/).map{|s|P[s]||P.invert[s]||s}.join})
while 9


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William James  
View profile   Translate to Translated (View Original)
 More options 24 Feb 2008, 21:26
Newsgroups: comp.lang.lisp, comp.lang.functional
From: William James <w_a_x_...@yahoo.com>
Date: Sun, 24 Feb 2008 13:26:38 -0800 (PST)
Local: Sun 24 Feb 2008 21:26
Subject: Re: a golden oldie challenge: Eliza
On Feb 24, 9:00 am, Dimitre Liotev <no...@email.com> wrote:

> Mark Tarver <dr.mtar...@ukonline.co.uk> writes:
> > Sorry I missed a couple of later attempts

> > Lisp                       150 LOC  ................ Peter Norvig
> > Qi (slightly revised)  63 LOC   .................Mark Tarver
> > Ruby                      53 LOC   .................William James
> > Q                           10 LOC   ..................Steven Apter
> > K                             3 LOC  ...................Steven Apter
> > Ruby (again)            17 LOC ...................William James
> > Mathematica            20 LOC .................. Szabolcs

> > Mark

> So K wins the competition in brevity,

I'm not so sure.  The three lines of K were not a
complete program.  I just posted a 4-line Ruby program
that does everything the Q program does.

>      but does the ability to squeeze
> code into illegible character blobs say anything about the suitability
> of a programming language for writing readable and understandable
> programs? I'd rather follow the principle that "Programs must be written
> for people to read, and only incidentally for machines to execute."...

If you really believe that, then you must agree that the
language used in your signature was designed to be easy
for a computer, not a human, to parse.

> --
> Dimitre Liotev
> (format t "~{~a~}" (reverse '("et" "n" "in." "a" "zn" "@" "l" "d")))

Ruby:

%w(et n in. a zn @ l d).reverse.join

Now that's easier for a human to read!  Of course, Lisp makes
it easy to have macros that generate code, which is a powerful
feature.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William James  
View profile   Translate to Translated (View Original)
 More options 24 Feb 2008, 21:35
Newsgroups: comp.lang.lisp, comp.lang.functional
From: William James <w_a_x_...@yahoo.com>
Date: Sun, 24 Feb 2008 13:35:20 -0800 (PST)
Local: Sun 24 Feb 2008 21:35
Subject: Re: a golden oldie challenge: Eliza

g**gle split some of the lines in my 4-line code above.
Let's make it 6 lines.

S =
  [ /father|mother|brother|sister/i, "Tell me about your 0."],
  [ /\b(am|i'm) (.*)/i, ["Why are you 2?","Have you always been 2?"]],
  [ /\bI was (.*)/i, ["Why were you 1?","I can't believe you were
1."]],
  [ /\bI will (.*)/i, "Do you think it's wise to 1?"],
  [ /\bI (.*)/i, "Why do you 1?" ],
  [ /\b(you|your|yours)\b/i, ["We're talking about you, not me.",
             "Please don't be so personal."]],
  [ /.*/, ["That's very interesting. Do go on.",
        "Tell me more.",
        "I'm not sure that I understand you fully.",
        "Can you elaborate on that?" ]]

P = Hash[ *"I|you|my|your|myself|yourself|you are|I am|you're|I am".
      split('|')]
( gets;sub(/[.!?,; ]+$/,"");x=Array(S.find{|a|$m=$_.match(a[0])}[1])
  puts x[rand(x.size)].gsub(/\d/){$m.to_a[$&.to_i].scan(
    /you are|you're|\w+|\W+/).map{|s|P[s]||P.invert[s]||s}.join}
) while 9


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Arved Sandstrom  
View profile   Translate to Translated (View Original)
 More options 25 Feb 2008, 17:16
Newsgroups: comp.lang.lisp, comp.lang.functional
From: Arved Sandstrom <asandstrom...@eastlink.ca>
Date: Mon, 25 Feb 2008 17:16:43 GMT
Local: Mon 25 Feb 2008 17:16
Subject: Re: a golden oldie challenge: Eliza

William James wrote:
> On Feb 24, 9:00 am, Dimitre Liotev <no...@email.com> wrote:
[ SNIP ]
>> Dimitre Liotev
>> (format t "~{~a~}" (reverse '("et" "n" "in." "a" "zn" "@" "l" "d")))

> Ruby:

> %w(et n in. a zn @ l d).reverse.join

> Now that's easier for a human to read!  Of course, Lisp makes
> it easy to have macros that generate code, which is a powerful
> feature.

And a succinct but not-quite-so-easy-to-read J version :-) -

; |. ;: 'et n in. a zn @ l d'

AHS
--
* change 'two' to '2' to email me


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brian Adkins  
View profile   Translate to Translated (View Original)
 More options 25 Feb 2008, 17:52
Newsgroups: comp.lang.lisp, comp.lang.functional
From: Brian Adkins <lojicdot...@gmail.com>
Date: Mon, 25 Feb 2008 09:52:13 -0800 (PST)
Local: Mon 25 Feb 2008 17:52
Subject: Re: a golden oldie challenge: Eliza
On Feb 24, 11:18 am, Dimitre Liotev <no...@email.com> wrote:

Boy, I have mixed emotions when reading that. On the one hand, I see
what at first glance appears to be a collection of random characters.
On the other hand, I recognize I have zero knowledge of K, so I'm
slightly curious about a language that seems to take conciseness to an
obscene level.

Here's a question. Would it be easier to add some verbosity and
formatting to make the above K program more readable to those who
don't know K, or to take a readable program in another language and
make it that short? :)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stevan Apter  
View profile   Translate to Translated (View Original)
 More options 25 Feb 2008, 21:58
Newsgroups: comp.lang.lisp, comp.lang.functional
From: "Stevan Apter" <encryptednos...@nsl.com>
Date: Mon, 25 Feb 2008 16:58:13 -0500
Local: Mon 25 Feb 2008 21:58
Subject: Re: a golden oldie challenge: Eliza

in k symbols like + are ambivalent:  x+y is addition, +x is transposition.
q is k with keywords for the unary case:  x+y is addition, flip x is
transposition.

in f we have one instance of a primitive with four arguments:  @[x;y;:;w].
so we can define:

    amend:{@[x;y;:;z]}

x?y finds y in x.  let's cover that as well, and give it infix syntax:

    .q.find:?

$[x;y;z;...] is the conditional.  

now rewrite f in q like this:

    f:{$[all x;enlist x;raze f each amend[x;i]each where 27=x[raze p i:x find 0]find til 10]}


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vanekl  
View profile   Translate to Translated (View Original)
 More options 7 Mar 2008, 04:32
Newsgroups: comp.lang.lisp
From: vanekl <va...@acd.net>
Date: Thu, 6 Mar 2008 20:32:33 -0800 (PST)
Local: Fri 7 Mar 2008 04:32
Subject: Re: a golden oldie challenge: Eliza
Joseph Weizenbaum :: January 8, 1923 - March 5, 2008 :: R.I.P.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google