Search found 55 matches

by fdb
Wed Aug 05, 2020 10:30 pm
Forum: So, what can you actually DO with newLISP?
Topic: Newlisp bindings for DuckDB
Replies: 0
Views: 5

Newlisp bindings for DuckDB

Hi, I've added newLISP bindings for DuckDB at https://github.com/luxint/duckdb So what is DuckDB? Have a look at their website: https://duckdb.org They state that : DuckDB is an embeddable SQL OLAP database management system In practice it is almost like SQLITE (only much faster!) so the API I made ...
by fdb
Thu Jul 23, 2020 7:11 pm
Forum: Whither newLISP?
Topic: where is the value which is assigned by setq to a symbol?
Replies: 4
Views: 593

Re: where is the value which is assigned by setq to a symbol?

Wel you either do

Code: Select all

> (set 'f 100)
100
> f
100
Or you do

Code: Select all

> (setq f 100)
100
> f
100
With set you have to quote because set evaluates its arguments, setq doesn't.
by fdb
Mon Jul 13, 2020 9:23 pm
Forum: So, what can you actually DO with newLISP?
Topic: Newlisp bindings for Termbox
Replies: 0
Views: 536

Newlisp bindings for Termbox

Hi,

I made Newlisp bindings to the Termbox library. With these bindings you can easily create text-based user interfaces in Newlisp. You can find it at https://github.com/luxint/termbox Let me know what you think or if you have any questions!
by fdb
Thu Jul 02, 2020 4:53 pm
Forum: newLISP in the real world
Topic: Sum of integers in a string
Replies: 7
Views: 168

Re: Sum of integers in a string

Or replacing the map with a function for apply, so only traversing the string two times

Code: Select all

> (apply (fn(x y) (+ (int x) (int y))) (find-all {[1-9]\d*} "o123p0010iru5") 2) 
138
by fdb
Thu Jul 02, 2020 4:27 pm
Forum: newLISP in the real world
Topic: Sum of integers in a string
Replies: 7
Views: 168

Re: Sum of integers in a string

Nice, I didn't know starts-with and didn't know I could use a regex in find-all, but then we could also simplify your code:

Code: Select all

> (apply + (map int (find-all {[1-9][0-9]*} "o123p010iru5")))
138
>
by fdb
Wed Jul 01, 2020 3:23 am
Forum: newLISP in the real world
Topic: Sum of integers in a string
Replies: 7
Views: 168

Re: Sum of integers in a string

Hi cameo,

my first attempt would be:

Code: Select all

(define (parse-str str)
  (apply + (map int (clean empty? (parse str {[^0-9]} 0)))))
if it needs to be faster I would do:

Code: Select all

(define (parse-str str)
	(let (total 0)
		(dolist (s (parse str {[^0-9]} 0))
			(unless (empty? s)
				(inc total (int s))))
		total))
by fdb
Sun Nov 24, 2019 10:08 am
Forum: newLISP in the real world
Topic: Puzzle
Replies: 5
Views: 1910

Re: Puzzle

ah yes to easy when n doesn't need to be a number...

Code: Select all

(define (f n)
  (if (number? n)
		(list n)
		(- (n 0))))
by fdb
Fri Nov 22, 2019 10:21 pm
Forum: newLISP in the real world
Topic: Puzzle
Replies: 5
Views: 1910

Re: Puzzle

The simplest i could think of is:

Code: Select all

(define-macro (f n)
  (- (n 1)))
But i do not know if macro's are allowed!
by fdb
Thu Jun 06, 2019 7:51 pm
Forum: newLISP newS
Topic: newLISP language support for Visual Studio Code
Replies: 9
Views: 3230

Re: newLISP language support for Visual Studio Code

Hi cameyo,

The keybindings are in the package.json file, have you tried reloading: view/command palette/developer:reload window? If you have customised keybindings (with keybindings.json) you may have keybinding conflicts.
by fdb
Mon Jun 03, 2019 10:46 pm
Forum: newLISP newS
Topic: newLISP language support for Visual Studio Code
Replies: 9
Views: 3230

Re: newLISP language support for Visual Studio Code

Hi, I've added the ability to evaluate selected expression(s), it will either send the current selection to the REPL or, if nothing is selected, it will select the 'first' expression within the cursor position to the REPL. This 'first expression' starts 1 position left to cursor if this is a opening...
by fdb
Sun Jun 02, 2019 12:12 pm
Forum: newLISP newS
Topic: newLISP language support for Visual Studio Code
Replies: 9
Views: 3230

Re: newLISP language support for Visual Studio Code

Hi cameyo, I had added the possibility to execute the active selection in the REPL but had problems getting it to work reliable so I chose to first release without it. My way of working is that I usually test my one liners in the repl first, for multi line functions I enter them in the editor, save ...
by fdb
Sat Jun 01, 2019 8:53 pm
Forum: newLISP newS
Topic: newLISP language support for Visual Studio Code
Replies: 9
Views: 3230

newLISP language support for Visual Studio Code

I've made a GitHub repository with language support for newLISP in Visual Studio code: https://github.com/luxint/vscode-newlisp . If you don't now VS Code have a look at https://code.visualstudio.com , a very nice free editor, built on open source, from Microsoft, runs on Windows, Mac and Linux. Cur...
by fdb
Tue May 28, 2019 5:50 pm
Forum: newLISP in the real world
Topic: Group the elements of a list
Replies: 10
Views: 1540

Re: Group the elements of a list

HI, cameyo, also here you can use a standard function: explode, see below: > (setq lst (sequence 0 9)) (0 1 2 3 4 5 6 7 8 9) > (explode lst 2) ((0 1) (2 3) (4 5) (6 7) (8 9)) > (explode lst 3) ((0 1 2) (3 4 5) (6 7 8) (9)) > (setq lst (sequence 1 12)) (1 2 3 4 5 6 7 8 9 10 11 12) > (explode (explode...
by fdb
Mon May 27, 2019 9:42 pm
Forum: newLISP in the real world
Topic: Nesting level of a list
Replies: 5
Views: 900

Re: Nesting level of a list

Not very elegant but maybe faster (for short lists I presume)

Code: Select all


(define (nesting lst prev (t 0))
	(if (= lst prev)
		t
	  (nesting (flat lst 1) lst (inc t))))


> (nesting '(a (((b c (d)))) (e) ((f)) g))
5
by fdb
Tue May 14, 2019 10:36 pm
Forum: So, what can you actually DO with newLISP?
Topic: Fun with primes (and newLISP)
Replies: 0
Views: 1316

Fun with primes (and newLISP)

I think newLISP is a great tool for tinkering with some ideas in your head, AKA 'exploratory computing'. If you like this as well maybe you'll also like the little write up below. Recently I had to explain 'what is a prime' to my eldest daughter, while explaining 'there are an infinite number of pri...
by fdb
Tue May 14, 2019 8:24 pm
Forum: newLISP newS
Topic: Stable Release newLISP v.10.7.5
Replies: 8
Views: 2191

Re: Stable Release newLISP v.10.7.5

Hi Lutz,

The 'macOS Intel executable 10.7.5' and the 'macOS dynamic library 64-bit UTF8' are .dms files (Amiga DMS Disk archive)? which I cannot extract (by the Unarchiver). if I change to extension to .dmg , no luck either.

mvg
Ferry
by fdb
Mon Feb 11, 2019 8:20 pm
Forum: Whither newLISP?
Topic: Retrieving the value of a symbol
Replies: 2
Views: 2066

Re: Retrieving the value of a symbol

Hi, I presume you want to convert a string into a symbol , which can be done like this: (set (sym "name") 3) name ->3 If you however want to convert "name" including quotes into a symbol then use this code: (set (sym {"name"}) 3) and to retrieve the value from "name": (eval (sym {"name"})) -> 3
by fdb
Fri Jan 25, 2019 9:11 pm
Forum: newLISP in the real world
Topic: csv to assoc-list
Replies: 9
Views: 1911

Re: csv to assoc-list

someting like:

Code: Select all

(set 'csv '(("a" "b") (1 2) (3 4) (5 6)))

(flat (map (fn(x) (map list (first csv) x)) (rest csv)) 1)

=> (("a" 1) ("b" 2) ("a" 3) ("b" 4) ("a" 5) ("b" 6))
by fdb
Sat Dec 22, 2018 12:38 pm
Forum: newLISP in the real world
Topic: anti-select elements of a list
Replies: 9
Views: 1479

Re: anti-select elements of a list

or use select and the difference of the selected indexes:

Code: Select all

(define (unselect lst sel)
	 (select lst (difference (sequence 0 (dec (length lst))) sel)))

> (unselect '(5 4 3 2 1) '(1 2))
(5 2 1)
by fdb
Fri Dec 21, 2018 4:39 pm
Forum: newLISP in the real world
Topic: anti-select elements of a list
Replies: 9
Views: 1479

Re: anti-select elements of a list

or just

Code: Select all

(difference '(0 1 2 3 nil) '(1 2))

(0 3 nil)
or am I misunderstanding something?
by fdb
Fri Dec 21, 2018 4:23 pm
Forum: newLISP in the real world
Topic: anti-select elements of a list
Replies: 9
Views: 1479

Re: anti-select elements of a list

Code: Select all

(define (unselect lst sel)
  (clean (fn(x) (member x sel)) lst))

(unselect '( 0 1 2 3 nil) '(1 2))

(0 3 nil)
by fdb
Mon Aug 27, 2018 8:42 pm
Forum: newLISP and the O.S.
Topic: Calling OBJC runtime from newlisp
Replies: 19
Views: 9586

Re: Calling OBJC runtime from newlisp

And as probably the final piece I imported the objc function to dynamically add a method (= function) to an existing class with a given implementation (function pointer) which gives you the possibility to execute a newlisp function when for instance clicking on a button. You'll have to define the fu...
by fdb
Wed Aug 22, 2018 11:03 pm
Forum: newLISP and the O.S.
Topic: Calling OBJC runtime from newlisp
Replies: 19
Views: 9586

Re: Calling OBJC runtime from newlisp

Coming back to this (after 4 years , time flies!) I've recently made a minimalistic objective-c/cocoa bridge which doesn't need any 'glue' c-code /libraries. You only need to import 3 functions from the libobjc.dylib and two frameworks (foundation and appkit) which are standard available on a Mac. I...
by fdb
Fri Aug 17, 2018 9:32 pm
Forum: newLISP in the real world
Topic: Any new releases, planned future
Replies: 5
Views: 1773

Re: Any new releases, planned future

Also thanks for the update Lutz and, supporting Bertrand, I also keep coming back to newLISP nothing compares to it! Regarding the IDE remarks from Lutz I've started with creating newlisp bindings for a platform independent native GUI library: libui https://github.com/andlabs/libui you can download ...
by fdb
Fri Dec 22, 2017 12:21 am
Forum: So, what can you actually DO with newLISP?
Topic: Neural network in Newlisp
Replies: 0
Views: 2131

Neural network in Newlisp

Interested in playing with neural networks and don't want to use or learn python? Now you can also use your favorite programming language! I've converted the python program written by Michael Nielsen from his his excellent on-line book at http://neuralnetworksanddeeplearning.com to newLisp. Presente...