Arc Forumnew | comments | leaders | submitlogin
5 points by kennytilton 5908 days ago | link | parent

I was remiss, I should have posted everything Steve offered on that snippet:

---------- BEGIN QUOTE ------------------------

   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]]}
it's just a single eye-watering case statement:

   if no keyword match in A, then return a default response from E
   else if no substitution in the response c picked from C, return c
   else substitute and return
it's easier to break the q code into smaller chunks. a revised version here: http://www.nsl.com/k/eliza.q

----------- END QUOTE ---------------------------