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

Topics - jopython

#1
I am trying to run newlisp behind inetd in -http mode with http-conf.lsp example provided in the manual.

The example provided in the manual is very limited and it exposes the entire newlisp interpreter to the http port which I find a security issue. I wish we had clojure compojure  like routes DSL for  newlisp.



(defroutes home-routes
  (GET "/" [] (home-page))
  (GET "/hello/:name" [name] (str  "Hello " name))
  (GET "/about" [] (about-page)))


Nice thing about compojure is that it exposes only these routes and nothing but these routes. Is there a DSL similar to this for newlisp and easy to use?
#2
newLISP in the real world / Pattern Matching
March 14, 2015, 10:04:56 AM
Once you get into ML languages, you get used to pattern matching:

Here is an factorial example in Shen.



(26-) (define factorial
    0 -> 1
    X -> (* X (factorial (- X 1))))
factorial

(27-) (factorial 6)
720


I wonder if anybody done anything like this for beloved newLisp?

Thanks and Cheers.
#3
The newlisp manual has predicates.

But I like to know if there is there a builtin function to find out the type of a symbol/variable/defn which I can use such as

eg:



(type x) => "list"
(type n) => "integer"
etc...
#4
What is the standard unit testing framework used by newlispers?

Thanks in advance.
#5
newLISP in the real world / Multiple dispatch?
November 09, 2014, 06:30:31 PM
This was probably discussed in this forum before. Has anyone succeeded adding multiple dispatch capability to  newLisp using a macro or otherwise?

http://en.wikipedia.org/wiki/Multiple_dispatch#Common_Lisp">//http://en.wikipedia.org/wiki/Multiple_dispatch#Common_Lisp

If newLisp had a feature which allowed parametric polymorphism, my code will look more cleaner as it grows in size.
#6
newLISP in the real world / comparative macrology
September 15, 2014, 06:34:54 PM
Just wanted to point someone mentioned and compared newlisp macros in his blog.



http://www.wilfred.me.uk/blog/2014/09/15/comparative-macrology/">//http://www.wilfred.me.uk/blog/2014/09/15/comparative-macrology/
#7
newLISP in the real world / how to expand list-map
August 17, 2014, 11:40:00 AM
The following function performs a map over two lists.

How to extend this abstraction where the numbers of lists are unknown instead of only two?



(define (list-map op lst1 lst2)
      (map (fn (x y) (op x y)) lst1 lst2))


For. eg

I should be able to  call

(list-map + '(1 2 3) '(3 4 4))

or



(list-map + '(1 2 3) '(5 6 7) '(8 9 10))



or even more number of lists as arguments
#8
Is there an issue with running the button demo on OpenJDK on 64 bit Ubuntu (14.04)?



:( ]$ java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

:( ]$ newlisp /usr/share/newlisp/guiserver/button-demo.lsp

newLISP-GS v.1.63 on Linux
Exception in thread "main" java.awt.HeadlessException
at sun.java2d.HeadlessGraphicsEnvironment.getDefaultScreenDevice(HeadlessGraphicsEnvironment.java:77)
at guiserver.<init>(guiserver.java:207)
at guiserver.main(guiserver.java:78)
^CERR: received SIGINT - in function sleep
called from user defined function gs:init

#9
newLISP in the real world / Newlisp and debugging
May 18, 2014, 10:41:54 AM
It becomes really painful to debug newlisp code if we get an error message like follows with no line number and there are 8 instances of the map function in my code :



ERR: list expected in function map : nil
#10
Is there a macro or library for list comprehensions in newlisp?



Something like this small one liner (eg in python) can come real handy.

>>> a = range(10)
>>> b = range(11,20)
>>> [[x, y] for x in b for y in a]


Which gives

[[11, 0], [11, 1], [11, 2], [11, 3], ......
#11
Are these errors normal.

$ make -f makefile_sunos
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS newlisp.c
newlisp.c: In function `evaluateExpression':
newlisp.c:1493: warning: ISO C90 forbids mixed declarations and code
newlisp.c: In function `p_apply':
newlisp.c:4686: warning: dereferencing type-punned pointer will break strict-aliasing rules
newlisp.c: In function `implicitNrestSlice':
newlisp.c:5382: warning: dereferencing type-punned pointer will break strict-aliasing rules
newlisp.c:5395: warning: dereferencing type-punned pointer will break strict-aliasing rules
newlisp.c: In function `p_mainArgs':
newlisp.c:7109: warning: dereferencing type-punned pointer will break strict-aliasing rules
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS nl-symbol.c
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS nl-math.c
nl-math.c: In function `randomDist':
nl-math.c:1335: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-math.c: In function `p_series':
nl-math.c:1915: warning: dereferencing type-punned pointer will break strict-aliasing rules
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS nl-list.c
nl-list.c: In function `explodeList':
nl-list.c:142: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-list.c: In function `p_lookup':
nl-list.c:589: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-list.c: In function `implicitIndexList':
nl-list.c:1022: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-list.c:1030: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-list.c:1060: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-list.c: In function `implicitIndexArray':
nl-list.c:2001: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-list.c:2009: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-list.c:2023: warning: dereferencing type-punned pointer will break strict-aliasing rules
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS nl-liststr.c
nl-liststr.c: In function `p_chop':
nl-liststr.c:359: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c: In function `p_push':
nl-liststr.c:475: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c:480: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c:540: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c: In function `p_pop':
nl-liststr.c:608: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c:613: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c:635: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c: In function `popString':
nl-liststr.c:670: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c:673: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c: In function `pushOnString':
nl-liststr.c:716: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c: In function `p_select':
nl-liststr.c:795: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c:799: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c:842: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c:846: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c: In function `p_slice':
nl-liststr.c:876: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c:878: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c: In function `p_find':
nl-liststr.c:1054: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c: In function `p_dup':
nl-liststr.c:1357: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-liststr.c: In function `p_rotate':
nl-liststr.c:1634: warning: dereferencing type-punned pointer will break strict-aliasing rules
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS nl-string.c
nl-string.c: In function `implicitIndexString':
nl-string.c:178: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-string.c: In function `p_char':
nl-string.c:281: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-string.c: In function `p_explode':
nl-string.c:381: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-string.c: In function `p_pack':
nl-string.c:1703: warning: dereferencing type-punned pointer will break strict-aliasing rules
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS nl-filesys.c
nl-filesys.c: In function `p_readBuffer':
nl-filesys.c:287: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-filesys.c: In function `writeBuffer':
nl-filesys.c:529: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-filesys.c: In function `p_share':
nl-filesys.c:2119: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-filesys.c:2127: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-filesys.c: In function `p_date':
nl-filesys.c:2472: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-filesys.c: In function `p_now':
nl-filesys.c:2649: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-filesys.c: In function `p_dateList':
nl-filesys.c:2726: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-filesys.c:2727: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-filesys.c: In function `p_dateValue':
nl-filesys.c:2763: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-filesys.c:2764: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-filesys.c:2765: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-filesys.c:2772: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-filesys.c:2773: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-filesys.c:2774: warning: dereferencing type-punned pointer will break strict-aliasing rules
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS nl-sock.c
nl-sock.c: In function `p_netReceive':
nl-sock.c:913: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-sock.c: In function `p_netReceiveUDP':
nl-sock.c:1052: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-sock.c: In function `p_netReceiveFrom':
nl-sock.c:1084: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-sock.c: In function `p_netSend':
nl-sock.c:1104: warning: dereferencing type-punned pointer will break strict-aliasing rules
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS nl-import.c
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS nl-xml-json.c
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS nl-web.c
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS nl-matrix.c
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS nl-debug.c
gcc -m32 -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUNOS pcre.c
gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o  nl-sock.o nl-import.o nl-xml-json.o nl-web.o nl-matrix.o nl-debug.o pcre.o -m32 -lm -ldl -lrt -lsocket -lnsl -o newlisp


Tests pass fine however.



$ make test
make check | grep '>>>'
>>>>> ALL FUNCTIONS FINISHED SUCCESSFUL: ./newlisp
>>>>> Dictionary API tested SUCCESSFUL
>>>>> XML API tested SUCCESSFUL
>>>>> XML callback tested SUCCESSFUL
>>>>> JSON translation tested SUCESSFUL
>>>>> Signal testing SUCCESSFUL
>>>>> Network eval and network file functions IPv4 SUCCESSFUL
>>>>> The Cilk API tested SUCCESSFUL
>>>>> Reference testing SUCCESSFUL
>>>>> Time per simple message: 31 micro seconds
>>>>> Time per round trip : 280 micros seconds
>>>>> Time per proxy trip: 110 micro seconds
>>>>> Message API tested SUCCESSFUL
>>>>> abs bigint float gcd length zero? + - * / % ++ -- big ints tested SUCCESSFUL
>>>>> Benchmarking all non I/O primitives ... (may take a while)
>>>>> total time: 16811.294
>>>>> Performance ratio: 6.56 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.5.7-64-bit)
#12
libc6 is not in



"/lib/libc.so.6"


At the latest versions of Ubuntu it is in

/lib/i386-linux-gnu/libc.so.6
/lib/i686-linux-gnu/libc.so.6
#13
Whither newLISP? / JSON encoder?
November 20, 2013, 07:33:28 PM
Is there a JSON encoder for newlisp?
#14
newLISP in the real world / Thousand's separator
November 04, 2013, 01:16:34 PM
Is there a newlisp built-in for a thousands separator? Say in python we can



In [5]: format(123456789,',d')
Out[5]: '123,456,789'
#15
newLISP in the real world / Iterator pattern like python?
September 08, 2013, 10:29:56 AM
Do we have a iterator pattern in newlisp like the one in python?





>>> lst = [3, 2, 1]
>>> s = iter(lst)
>>> s
<listiterator object at 0xb741e0cc>
>>> s.next()
3
>>> s.next()
2
>>> s.next()
1
>>> s.next()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
StopIteration



Here 's' is an object AND not a copy of the original list.
#16
Anything else we might add? / Reducers in newlisp?
August 30, 2013, 12:12:13 PM
Is it possible to have to have reducers in newlisp too as mentioned in this http://adambard.com/blog/Reducers-explained-through-Python/">//http://adambard.com/blog/Reducers-explained-through-Python/ ?



The key takeaway from the article is
Quote
This is the idea behind reducers. If you take your mapping function (map, filter, flatten, etc.), and have it modify the reducing function, you can perform any number and combination of mappings without having to repeatedly iterate through the list.
#17
newLISP in the real world / What happened to "if-not"?
August 30, 2013, 07:44:44 AM
I see that if-not has been deprecated in the manual. But  the code patterns document for 10.5.0 still mentions it.
#18
Is it possible to use compiled regex with the ends-with function?



(set 'dt (regex-comp {(w+)}))

(ends-with "delta" dt 0x10000)  => ERR: regular expression in function ends-with : "error -4 when executing"

#19
I have a list of symbols in a list named 'mems'

How do i extract the "values" of those symbols instead of the symbols themselves?





: mems
(s1 s2 s3 s4 s5)

: s1
("hi")

: (map symbol? mems)
(true true true true true)

#20
Is there a Parallel version of map (which internally uses spawn) where we can control the number of procs used and timeout?



Something like



(parallel-map func seq max-procs timeout)


This is for utilizing multiple processors instead  of the regular map which is sequential.