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 - newBert

#31
I'm not a regular user of newLISP-GS(*) but I think you might try gs:set-selected...



(*) [size=85]I feel more comfortable with newLISP-Tk[/size]
#32
Quote from: "TedWalther"By default, we perceive an array as a special case of a list; so we expect it to act like a like in pretty much every way.


Yes, but we can't effectively create an empty array :
newLISP v.10.7.1 32-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h

> (array 0)

ERR: wrong dimensions in function array : 0
>

If we'd like to consider an array as a special case of a list, we must think it's above all a non-empty list.

So, the use of empty? with an array seems to be  an incoherence, or even a nonsense... and it's not so bad that an error message reminds us of it :)
#33
newLISP in the real world / Re: Expand..
June 24, 2016, 09:24:30 AM
Quote from: "derek" I never managed to get quite good enough at lisp and scheme, but with newlisp I should be vaguely useful for something..



:)


I myself tried some Lisp(s) and many Scheme(s), and other scripting languages too, like Python, Perl or Ruby, but I'm definetly not able to manage with them, and at the end I come back again and again to NewLISP, (and Lua, equally placed with NewLISP as my favorite languages) :)
#34
newLISP in the real world / Re: Expand..
June 22, 2016, 08:32:02 AM
Quote from: "derek"Maybe I'm doing something wrong but I can't get expand to work..



(set 'x 2 'a '(d e)) ; from the examples



(expand '(a x(b c x) 'x 'a))



For me this just returns the first list I typed.  But I'm just using this on the console, not in any macros.. is this possible??



Many thanks.


In the example, we have : (expand '(a x (b c x)) 'x 'a) which returns -> ((d e) 2 (b c 2)).

But you wrote (expand '(a x(b c x) 'x 'a)) ...
#35
Here is another solution :


(set 'foo '(1 5 10 20 100 105))
(last (ref-all 50 foo > true))   ;-> 20
#36
Here are some comparisons between Python and NewLisp  that I made a long time ago:


;; List Comprehensions in PYTHON

;;>>> vec = [2, 4, 6]
;;>>> [3*x for x in vec]
;;[6, 12, 18]

(set 'vec '(2 4 6))
(println (map (lambda (x) (* x 3)) vec))
;-> (6 12 18)

;;>>> vec = [2, 4, 6]
;;>>> [[x, x**2] for x in vec]
;;[[2, 4], [4, 16], [6, 36]]

(println (map (lambda (x) (list x (pow x))) vec))
;-> ((2 4) (4 16) (6 36))

;;>>> freshfruit = ['  banana', '  loganberry ', 'passion fruit  ']
;;>>> [weapon.strip() for weapon in freshfruit]
;;['banana', 'loganberry', 'passion fruit']

(set 'freshfruit '("  banana" "  loganberry " "passion fruit  "))
(println (map trim freshfruit))
;-> ("banana" "loganberry" "passion fruit")

;;>>> [3*x for x in vec if x > 3]
;;[12, 18]
;;>>> [3*x for x in vec if x < 2]
;;[]

(println (map (lambda (x) (when (> x 3)(* x 3)))vec))
;-> (nil 12 18)
(println (map (lambda (x) (when (< x 2)(* x 3))) vec))
;-> (nil nil nil)

;;>>> vec1 = [2, 4, 6]
;;>>> vec2 = [4, 3, -9]
;;>>> [x*y for x in vec1 for y in vec2]
;;[8, 6, -18, 16, 12, -36, 24, 18, -54]

(set 'vec1 '(2 4 6))
(set 'vec2 '(4 3 -9))
(dolist (x vec1)(dolist (y vec2)(print (* x y) " ")))
(println)
;-> 8 6 -18 16 12 -36 24 18 -54

;;>>> [x+y for x in vec1 for y in vec2]
;;[6, 5, -7, 8, 7, -5, 10, 9, -3]

(dolist (x vec1)(dolist (y vec2)(print (+ x y) " ")))
(println)
;-> 6 5 -7 8 7 -5 10 9 -3

;;>>> [vec1[i]*vec2[i] for i in range(len(vec1))]
;;[8, 12, -54]

(println (map * vec1 vec2))
;-> (8 12 -54)

;;>>> mat = [
;;...        [1, 2, 3],
;;...        [4, 5, 6],
;;...        [7, 8, 9],
;;...       ]
;;>>> print([[row[i] for row in mat] for i in [0, 1, 2]])
;;[[1, 4, 7], [2, 5, 8], [3, 6, 9]]
;; ou
;;>>> list(zip(*mat))
;;[(1, 4, 7), (2, 5, 8), (3, 6, 9)]

(set 'matrix '((1 2 3)(4 5 6)(7 8 9)))
(println (transpose matrix))
;-> ((1 4 7) (2 5 8) (3 6 9))

;;for i in [0, 1, 2]:
;;    for row in mat:
;;        print(row[i], end="")
;;    print()

(dolist (row (transpose matrix)) (println row))
;-> (1 4 7)
;   (2 5 8)
;   (3 6 9)
#37
Anything else we might add? / Re: new to newLISP
October 17, 2010, 02:57:18 AM
Quote from: "Ormente"Hi everybody !



I'm a new newLISPer from France, and very happy to have found this pragmatic LISP.

Hello Ormente,

I'm a french NewLisper too ... a kind of ghost, in french "revenant" (= who is coming back), because I had given up programing a while ago.

I'm not a pro but I like NewLisp even if I made some diversions to Rebol, Lua, Euphoria, etc.

At present I use above all http://www.fbsl.net/homepage.html">FBSL, http://www.elica.net/site/index.html">ELICA and of course NewLISP ... just for the fun, most of the time.

:-)



NewLISP-GS[/i] is quite usable despite that, and in any case easy to use.
#38
newLISP and the O.S. /
September 28, 2009, 07:50:31 AM
For me on Win XP with NewLISP 10.1.5 :


QuotenewLISP v.10.1.5 on Win32 IPv4, execute 'newlisp -h' for more info.



> (directory? "c:")



ERR: string token too long : "c:")rn"

> (directory? "c:\")

nil

> (directory? {c:})

nil

> (directory? {c:\})

true

>


and :


Quote> (directory? "c:/")

nil

> (directory? "")



ERR: string token too long : "")rn"

> (directory? "\")

nil

> (directory? "\.")

true

> (directory? "/.")

true

>
#39
newLISP in the real world /
July 26, 2009, 03:40:36 AM
Curious indeed !


newLISP v.10.1.1 on Win32 IPv4, execute 'newlisp -h' for more info.

> (context 'NEWCTX)
NEWCTX
NEWCTX> (set '$myvar 123)
123
NEWCTX> (context MAIN)
MAIN
> $myvar
123
> NEWCTX:$myvar
nil
>


but ...


newLISP v.10.1.1 on Win32 IPv4, execute 'newlisp -h' for more info.

> (setq NEWCTX:$myvar 123)
123
> $myvar
nil
> NEWCTX:$myvar
123
>
#40
Anything else we might add? /
July 18, 2009, 08:13:00 AM
Fine! I'll put them in my Nokia ... :-)
#41
newLISP newS /
July 13, 2009, 01:55:55 AM
I like Rebol very much but personally I don't like that proliferation of datatypes when we can easily create ours own (in NewLISP as well as in Rebol moreover) if need be.



So we can "personalize" or adapt the type(s) to the actual situation without cluttering the core of the language ... I think many datatypes can be reduced to/composed of simpler few common types (number, string, list).

IMHO ;-)
#42
Whither newLISP? /
May 31, 2009, 01:07:37 AM
I think do is ambiguous. In some languages like Lua, Euphoria it is used to begin a block but it probably evals the block too. In any rate one would think so.



dotimes and dolist (in NewLISP) gives me the same impression. I think that begin is more expressive even if we don't find the correlated end, useless in NewLISP because of the (closing/ending) brackets.



We could say "block" instead of "begin" but IMHO it's not a very pretty word

;-)



P.S.: finally a block with begin is evaluated too. So ... do or begin ?
#43
newLISP newS /
May 31, 2009, 12:47:30 AM
Quote from: "ale870"
I like map usage for multiple assignment!


Me too ... With (map set ...) you can also swap easily and neatly


newLISP v.10.0.6 on Win32 IPv4, execute 'newlisp -h' for more info.

> (map set '(a b c d e f) '(1 2 3 4 5 6))
(1 2 3 4 5 6)
> (map set '(a b c d e f) (list b c a e f d))
(2 3 1 5 6 4)
>


as in Python with tuples:

a, b, c, d, e, f = 1, 2, 3, 4, 5, 6 and a, b, c, d, e, f = b, c, a, e, f, d



;-)
#44
Quote from: "DekuDekuplex"


Apparently, carriage returns typed within the REPL in newLISP-GS are not being processed properly; viz.:



In the newLISP command prompt REPL, outside the IDE:


newLISP v.10.0.1 on Win32 IPv4, execute 'newlisp -h' for more info.

> [cmd]
1
[/cmd]
1
>


In the newLISP-GS REPL, inside the IDE:


> [cmd]
1
[/cmd]
nil
1
nil
1
>


-- Benjamin L. Russell


Yes, I confirm, same problem on my computer ... :-/
#45
newLISP Graphics & Sound /
March 11, 2009, 02:09:33 AM
Just to inform : no problems for me with newLISP v.10.0.2 on Win32 IPv4 (Windows XP-SP3,french version)  with both console and newlisp-GS