Search found 64 matches

by fdb
Wed Oct 28, 2020 9:34 pm
Forum: newLISP in the real world
Topic: Get rid of (some of) the parentheses with sublisp!
Replies: 1
Views: 32

Re: Get rid of (some of) the parentheses with sublisp!

As a final 'pièce de résistance' a much better and faster convert function (down) and one to add the parentheses (up, watch the regex option/number), also file versions and of course in the sublisp syntax ! ;-) (define (down txt) (replace {\)\)+} txt (string ")" (char (+ 0x2080 (length $it)₄ 0)₂ (de...
by fdb
Tue Oct 27, 2020 10:24 pm
Forum: newLISP in the real world
Topic: Get rid of (some of) the parentheses with sublisp!
Replies: 1
Views: 32

Get rid of (some of) the parentheses with sublisp!

I really like (new)lisp and even the parentheses but they can get kind of annoying, especially at the end of function so in a flash of insight I got the idea to replace the right parentheses with a subscripted count if there is more then one, see below original code: (define (initial-clauses str) (s...
by fdb
Tue Sep 29, 2020 6:29 pm
Forum: newLISP Graphics & Sound
Topic: is newlisp GS / guiserver abandoned ?
Replies: 1
Views: 262

Re: is newlisp GS / guiserver abandoned ?

Hi , You can still download it, but as stated on http://www.newlisp.org/index.cgi?Code_Contributions The Java based GUI server shipped until newLISP v.10.7.3: http://newlisp.org/code/guiserver-1.67.tgz . It contains an editor and demo files showing how to write graphics programs using guiserver.lsp ...
by fdb
Tue Sep 01, 2020 5:45 pm
Forum: newLISP in the real world
Topic: using ref data
Replies: 5
Views: 371

Re: using ref data

Hi joejoe , the best way to get the data would be to map over the results and use implicit indexing. So ref-all would give you a list of indices, probably the data you're looking for is one level up in this structure, then I would do: (map (fn(x) (itunes-data (chop x))) (ref-all "Brian Eno" itunes-d...
by fdb
Sat Aug 29, 2020 5:18 pm
Forum: Whither newLISP?
Topic: "place" in the function "inc"
Replies: 3
Views: 653

Re: "place" in the function "inc"

In your example the 0 after inc in the lambda list is changed by inc. Your lambda list says :(define (sum (x 0)) (inc 0 x)) after you do (sum 1) your lambda list is : (define (sum (x 0)) (inc 1 x)), so the 0 has become a 1. after you do another (sum 1) your lambda list is : (define (sum (x 0)) (inc ...
by fdb
Wed Aug 26, 2020 2:30 pm
Forum: Whither newLISP?
Topic: "place" in the function "inc"
Replies: 3
Views: 653

Re: "place" in the function "inc"

It refers to a place in a list, so you can do:

Code: Select all

> (set 'places '(0 0 0))
(0 0 0)
> (inc (places 1))
1
> places
(0 1 0)
> 
See also setq which also updates places.

The example from Code Patterns illustrates that a function is also a list (a lambda list) and you can also update that list with inc.
by fdb
Tue Aug 25, 2020 4:06 pm
Forum: So, what can you actually DO with newLISP?
Topic: Newlisp bindings for DuckDB
Replies: 1
Views: 564

Re: Newlisp bindings for DuckDB

Hi,

I've added a pivot command to the bindings, which allows for generating pivot tables (like in excel) over tables with millions of records, which is not possible in excel. Have a look at https://github.com/luxint/duckdb, which shows several examples.
by fdb
Thu Aug 13, 2020 7:45 pm
Forum: newLISP in the real world
Topic: Find single number
Replies: 4
Views: 329

Re: Find single number

Very nice! An instruction I've never used in practice.
by fdb
Wed Aug 12, 2020 6:44 am
Forum: newLISP in the real world
Topic: Find single number
Replies: 4
Views: 329

Re: Find single number

HI Cameyo, I would do something like this, using a hash table: (define (find-number lst) (define Myhash:Myhash) ; hash table creation, O(1) lookup time (set ' total 0) (dolist (n lst) (if (Myhash n) (dec total n) ; decrease when already added before (begin (Myhash n true) (inc total n)))) ; if not i...
by fdb
Wed Aug 05, 2020 10:30 pm
Forum: So, what can you actually DO with newLISP?
Topic: Newlisp bindings for DuckDB
Replies: 1
Views: 564

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: 865

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: 975

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: 501

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: 501

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: 501

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: 2248

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: 2248

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: 3845

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: 3845

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: 3845

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: 3845

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: 1897

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: 1117

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: 1772

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: 2719

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