Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - methodic

#1
Quote from: "cormullion"Although - after a coffee - I thought that


(set 'L '(("one" "two") ("for" "you")))
    (map append (L 0) (L 1))
)


was easier if you knew there were just two elements..

Bah, transpose is what I was looking for, thanks! Here is what I was looking to do:

I had a list of lists of scores, and wanted to add all scores with their respective index:
(map (fn (x) (apply add x)) (map append (transpose scores)))
#2
newLISP in the real world / Applying multiple lists?
March 11, 2011, 04:54:24 PM
Hi there,



Having a brain-fart, I blame it on dropping my morning coffee by accident before finishing it.



I have a list with multiple lists inside, and I'd like to map a function to each list as if I were passing them separately to map.



Example:

(map append '("one" "two") '("for" "you")) will render ("onefor" "twoyou").



I'd like to accomplish that, but if the argument to map is one list, with multiple lists. Sort of like this psuedo-code:

(map append (map each mylist))



Of course I could write a primitive function called "each" that did nothing but return a single element, but I figured that would be taking the long road since I'm sure newLisp has something built in I'm missing.



Thanks in advance!
#3
newLISP in the real world / Re: A bug perhaps?
February 03, 2011, 09:41:20 AM
Sorry for the noise Lutz, the bug was due to the shared library. It had to do with AES encryption, and the subroutine was expecting a NULL terminated block-size string of 64 bytes.
#4
newLISP in the real world / A bug perhaps?
January 31, 2011, 03:52:13 PM
Hi,



I have a newLISP script that uses a shared library, and upon passing it a specific argument (JSON) with a specific length (63 characters), I am able to crash newLISP.



Here is the string that crashes it:
(set 'test "{"ID":"somedumbuser@ahost.com","DEBUG":"why does this crash63"}")
These, however, will not crash newLISP:
(set 'test "{"ID":"somedumbuser@ahost.com","DEBUG":"why does this crash6"}")
(set 'test "{"ID":"somedumbuser@ahost.com","DEBUG":"why does this crash630"}")

GDB outputs the following, I tested this against 10.2.8 and 10.2.18:
Program received signal SIGSEGV, Segmentation fault.
copyCell (cell=0x10009) at newlisp.c:2013
2013 newCell->type = cell->type;
(gdb) bt
#0  copyCell (cell=0x10009) at newlisp.c:2013
#1  0x0804be82 in copyCell (cell=0x10009) at newlisp.c:2030
#2  0x08054409 in p_println (params=0x8089e20) at newlisp.c:5749
#3  0x0804e308 in evaluateExpression (cell=0x808ba20) at newlisp.c:1389
#4  0x08052361 in evaluateStream (stream=0xbffffa1c, outDevice=0, flag=1) at newlisp.c:1116
#5  0x080525c5 in loadFile (fileName=0xbffffddc "./test.lsp", offset=0, encryptFlag=0, context=0x8099e28) at newlisp.c:2995
#6  0x08053332 in main (argc=2, argv=0xbffffc84) at newlisp.c:733


Thanks!
#5
newLISP and the O.S. / Re: Loading libraries on OSX
January 01, 2011, 12:42:15 PM
Ah, thanks Lutz, good catch. It indeed was a 32bit vs 64bit issue.



Hope you had a happy new years!



-Tony.
#6
newLISP and the O.S. / Loading libraries on OSX
January 01, 2011, 10:44:17 AM
Running Snow Leopard, latest version of NewLISP. Trying to use the memcached.lsp file, but NewLISP is having trouble importing the library which was installed via macports:
> (import "/opt/local/lib/libmemcached.5.dylib" "memcached_create")

ERR: problem loading library in function import : "dlopen(/opt/local/lib/libmemcached.5.dylib, 9): no suitable image found.  Did find:nt/opt/local/lib/libmemcached.5.dylib: mach-o, but wrong architecture"


I didn't build libmemcached with any special arguments, just "port install libmemcached".



Any tips/ideas? Thanks in advance.
#7
newLISP in the real world / Re: Question about spawn
December 18, 2009, 02:00:08 PM
Sorry for the noise everyone, it appears that the children were just exiting faster than expected. I used the primes example script and saw 4 newlisp processes running. At least now I know for sure it works. :)
#8
newLISP in the real world / Question about spawn
December 18, 2009, 01:12:09 PM
Hi, in my application I have a dotimes call that for each iteration calls spawn which calls another function. The problem is that when running top I only see one lisp process when I know the loop should be spawning at least 4 separate processes.



I am running top with full command line args and the ability to see the CPU type for each CPU. When it is running, each CPU will never report over 100% usage simultaneously.... if one CPU is using 75% from the lisp script, the other CPU is showing 25% instead of both maxing out at 100%. All I ever see is one newlisp process taking up 100% CPU usage.



This is the latest stable release running under Linux.



Thanks in advance.
#9
Thanks, I tried defining MAIN:K just without the tick. That solution worked. :)
#10
I am running into this issue -- when trying to use the bayes functions in context MAIN, it works as expected. When trying to use these in a defined function, I am getting an error with bayes-query.


> (bayes-train '(A A B C C) '(A B B C C C) 'L)
(5 6)
> (bayes-query '(A C) L)
(0.579614219 0.420385781)

> (context 'TEST)
TEST
TEST> (bayes-train '(A A B C C) '(A B B C C C) 'L)
(5 6)
TEST> (bayes-query '(A C) L)

ERR: context expected in function bayes-query : TEST:L


Anyone have any insight as to why this is happening? Am I not defining something properly?



Thanks in advance.
#11
newLISP newS / Re: libmemcached api
December 17, 2009, 09:56:05 AM
Hey Jeff:



This seems to work for me:
(define (get-key key , res (value-length 0) (flags 0))
  (when MEMCACHED
    (setq res (memcached_get MEMCACHED
                             key (length key)
                             (address value-length)
                             (address flags)
                             (address MEMCACHED_RETURN)))
    ;(unless (zero? res) (get-string res))))
    (if (zero? res)
      nil
      (get-string res))))

I commented out the unless in case you wanted to format it differently.

> (load "memcached.lsp")
MAIN
> (memcached:init)
true
> (memcached:add-server "localhost" 11211)
true
>  (memcached:get-key "TEST")
nil
>  (memcached:set-key "TEST" "testing" 60)
"testing"
>  (memcached:get-key "TEST")
"testing"
> (sleep 60000)
60000
>  (memcached:get-key "TEST")
nil


Hope this was helpful, thanks!!
#12
newLISP in the real world / Embedded lists with match?
December 16, 2009, 10:27:01 AM
Is something like this possible:
(set 'lst '("key ("this one" "that one" "other one")))
(match '(? ("that one")) lst)

Basically I need to go backwards in referencing the key with one of it's elements.



Thanks in advance!
#13
newLISP newS / Re: libmemcached api
December 15, 2009, 05:57:00 AM
Sure, I will dig into it and see what's going on. I just wanted to make sure it wasn't PEBKAC. :)
#14
newLISP newS / Re: libmemcached api
December 14, 2009, 09:06:18 PM
Hi Jeff.



Thanks for the code... unfortunately I don't seem to be able to get it working correctly under 10.1.7. I load the .lsp file, do a memcached:init, memcached:add-server (I know the server is running and works)... and then when I do a memcached:get-key <some_key> that I know for sure doesn't exist, the function returns true.


> (load "memcached.lsp")
MAIN
> (memcached:init)
true
> (memcached:add-server "localhost" 11211)
true
> (memcached:get-key "doesnt_exist")
true


Am I doing something wrong/stupid? :)
#15
Hi, is there a way to import or use #define's from a library?



Thanks!