Search found 88 matches

by ssqq
Wed Jan 07, 2015 2:15 pm
Forum: Anything else we might add?
Topic: un-declared symbol name would set to nil
Replies: 2
Views: 5041

Re: un-declared symbol name would set to nil

Thanks, most of bug that difficulty to find is these type error. I am writing a strict code tools to check un-declared symbol beside it is a global symbol by explicit defined (like: $symbol-name).
by ssqq
Wed Jan 07, 2015 2:10 pm
Forum: Anything else we might add?
Topic: *(quote fn) or (quote lambda)* error
Replies: 2
Views: 5331

*(quote fn) or (quote lambda)* error

Following code would throw error:

Code: Select all

> 'fn
ERR: invalid lambda expression : "fn\n"
> 'lambda
ERR: invalid lambda expression : "lambda\n"
> (quote fn)
ERR: invalid lambda expression : " fn)\n"
> (quote lambda)
ERR: invalid lambda expression : " lambda)\n"
If it is a bug?
by ssqq
Tue Jan 06, 2015 8:14 am
Forum: Anything else we might add?
Topic: lexical declare function
Replies: 2
Views: 5265

lexical declare function

In newLISP, lexical symbol is declare with *let*, *letn*, *letex* and *args expression*. If it is possible that add *Perl-lish* style lexical declare function like *my*(expr scope) in newLISP? (define (sub-name arg) (expression-list) (my lexical-symbol 1) (+ 1 lexical-symbol)) (= lexical-symbol nil)...
by ssqq
Mon Jan 05, 2015 5:23 pm
Forum: newLISP in the real world
Topic: How to make *balanced* indent
Replies: 1
Views: 2001

Re: How to make *balanced* indent

;; indent-newlisp.lsp ;; Author: ssqq ;; http://www.newlisp.cn ;; usage: ;; ~> newlisp indent-newlisp.lsp your-script.lsp 4 > output.lsp (define (indent-code input-file (indent 2)) (local (v-level new-level file-txt file-lines indent-line indent-lines) (setq v-level 0) (setq file-text (read-file in...
by ssqq
Mon Jan 05, 2015 9:32 am
Forum: newLISP in the real world
Topic: How to make *balanced* indent
Replies: 1
Views: 2001

How to make *balanced* indent

I used Vim to write newLISP code, How to set following indent: (define (sub-name args) (built-in-sub args) ) (if (= expr nil) (dosth) ) if last parenthesis is first char of line, have same indent with his corresponding start parenthesis. Just like *{ ... }* in C-like indent.
by ssqq
Mon Jan 05, 2015 7:52 am
Forum: Anything else we might add?
Topic: un-declared symbol name would set to nil
Replies: 2
Views: 5041

un-declared symbol name would set to nil

As write newLISP code, if write a spell error symbol name, newLISP would make it as nil, and continue run. How to check these error? If have any tools could help me?
by ssqq
Mon Jan 05, 2015 6:35 am
Forum: Anything else we might add?
Topic: function *replace* could not catch $0, $1 in Ubuntu 14.04
Replies: 2
Views: 4887

Re: function *replace* could not catch $0, $1 in Ubuntu 14.0

yes, I write error code. I found the int-option in replace is could not ignore like *regex*. if ignore the int-option, newLISP would make "find-str" as *literal str*, if add int-option, newLISP would treat *find-str* as *regex-str". (replace "(a)" "aabb" "c") => "aabb" > (replace "(a)" "aabb" "c" 0)...
by ssqq
Fri Jan 02, 2015 11:59 am
Forum: Anything else we might add?
Topic: function *replace* could not catch $0, $1 in Ubuntu 14.04
Replies: 2
Views: 4887

function *replace* could not catch $0, $1 in Ubuntu 14.04

When I test *repace* in ubuntu 14.04, I found following test would fail:

(set 'str "---axb--ayb---")
(replace "(a)(.)(b)" str (append $3 $3 $1) 0)
(= str "---bxa---bya---")
by ssqq
Wed Nov 05, 2014 6:56 am
Forum: So, what can you actually DO with newLISP?
Topic: How to set a local 'Contexts Hash'
Replies: 6
Views: 9501

Re: How to set a local 'Contexts Hash'

In bigger project, Context as hash in function maybe pollute global symbol tree.

Code: Select all

(define (make-local-hash)
  (let (local-hash (new Tree 'a-hash))
    (a-hash "one" 1)
    (a-hash "two" 2)
))

(set 'a-hash 2)
(println a-hash) ; => 2
(make-local-hash)
(println a-hash) ; => a-hash

(exit)
by ssqq
Tue Nov 04, 2014 6:48 am
Forum: So, what can you actually DO with newLISP?
Topic: How to set a local 'Contexts Hash'
Replies: 6
Views: 9501

How to set a local 'Contexts Hash'

When default functor used as a pseudo hash function, How to set a local 'Hash'? Because Context is global.

Code: Select all

(define (check-key x)
    ;; I don't know whether environment have defined this symbol
    (define aHash:aHash)
    (aHash 'key-1 1)
    (aHash 'key-2 2)
    (if (aHash x) true nil))
by ssqq
Tue Nov 04, 2014 6:38 am
Forum: So, what can you actually DO with newLISP?
Topic: How to call function each other with declaration
Replies: 3
Views: 5841

Re: How to call function each other with declaration

Thanks all, I have not test this case. Because I found newlisp must decalare the function in advance before use it. So I think this case may throw a error.
by ssqq
Mon Nov 03, 2014 12:40 pm
Forum: So, what can you actually DO with newLISP?
Topic: How to call function each other with declaration
Replies: 3
Views: 5841

How to call function each other with declaration

If I design a function, need call other function which also call this function. How to Decalare it:

(define (sub-1 arg)
(if (> arg 1) (sub-2 arg)))

(define (sub-2 arg)
(if (< arg 1) (sub-1 arg)))
by ssqq
Thu Jul 17, 2014 3:55 am
Forum: Anything else we might add?
Topic: Invalid function "net-ping" and "net-packet"
Replies: 1
Views: 4809

Invalid function "net-ping" and "net-packet"

Code: Select all

newLISP v.10.6.0 32-bit on Win32 IPv4/6 libffi, options: newlisp -h
> (net-ping "192.168.1.253")

ERR: invalid function : (net-ping "192.168.1.253")
> (primitive? net-ping)
nil
> (net-packet)

ERR: invalid function : (net-packet)
> (primitive? net-packet)
nil
by ssqq
Sun Jul 13, 2014 6:28 pm
Forum: Anything else we might add?
Topic: context should be orthometric
Replies: 0
Views: 4941

context should be orthometric

Because the context is global, so the dictionary implemented with factor is global constants variable. any module which use factor would pollute other modules namespace. any list or string implements with factor which could pass reference to function also is global variable, It has same problem when...
by ssqq
Sun Jul 13, 2014 6:15 pm
Forum: Anything else we might add?
Topic: array literals
Replies: 0
Views: 4476

array literals

I think newLISP should add syntax of "array literals", but [..] have been used by symbol. without "array literals", a list with elements need evaluted is as following: (set 'str-quote (char 34)) (set lst (list str-quote (list str-quote))) If add [..] as array literal: (set 'arr [str-quote [str-quote...
by ssqq
Thu Jul 03, 2014 3:13 pm
Forum: Anything else we might add?
Topic: quote of large string
Replies: 0
Views: 4494

quote of large string

> (let (file "temp.txt") (write-file file (append "[text]" (dup "[text]" 5) "[/text]")) (eval-string (read-file "temp.txt"))) "[text][text][text][text][text]" > (let (file "temp.txt") (write-file file (append "[text]" (dup "[/text]" 5) "[/text]")) (eval-string (read-file "temp.txt"))) nil quote of ...
by ssqq
Thu Jun 26, 2014 8:52 am
Forum: Anything else we might add?
Topic: flat enough?
Replies: 4
Views: 6175

Re: flat enough?

If other dialect of lisp could match your expect? Common Lisp or Clojure? cljs.user> (flatten '('(1 2) (3 4))) (quote 1 2 3 4) Common Lisp have not buil-in flatten function: (defun flatten (obj) (do* ((result (list obj)) (node result)) ((null node) (delete nil result)) (cond ((consp (car node)) (whe...
by ssqq
Thu Jun 19, 2014 10:06 am
Forum: Anything else we might add?
Topic: more functions from the newLISP shared library
Replies: 0
Views: 4576

more functions from the newLISP shared library

I learned from "newlisp code Pattern":
; import functions from the newLISP shared library
(import LIBRARY "newlispEvalStr")
If I want know more functions could use from newLISP shared library, Where I should go?
by ssqq
Thu Jun 19, 2014 10:01 am
Forum: newLISP in the real world
Topic: How to design a function like Clojure 'iterate'
Replies: 4
Views: 3865

Re: How to design a function like Clojure 'iterate'

richyboy, yes, you are right. I think so.
by ssqq
Wed Jun 18, 2014 6:30 pm
Forum: newLISP in the real world
Topic: How to design a function like Clojure 'iterate'
Replies: 4
Views: 3865

How to design a function like Clojure 'iterate'

Following code could make a infinite sequence: (define (f) (begin (println (inc cnt)) (push (last f) f -1) (if (> (length f) 3) (pop f 1)))) But it is not lazy list: (first (f)) --> not 1 How to design a infinite sequence just like iterate and take in Clojure. (take 10 (iterate inc 5))
by ssqq
Tue Jun 17, 2014 2:55 am
Forum: newLISP in the real world
Topic: make a function like lambda
Replies: 2
Views: 2562

Re: make a function like lambda

Thanks ralph.ronnquist! I want make a extend enviroment (context) to prevent all primitive function to evualte. (new Class 'extend-env) (define (create-funcs f) (set (eval f) (append (lambda ()) (list (list 'cons f '(args)))))) (setq built-in (difference (filter eval (symbols)) '(define context MAIN...
by ssqq
Mon Jun 16, 2014 5:50 pm
Forum: newLISP in the real world
Topic: make a function like lambda
Replies: 2
Views: 2562

make a function like lambda

I want design a function:

Code: Select all

(context 'extend-env)
(extend-env:filter 1 2 3) --> (extend-env:filter 1 2 3)
In this context, some primitive function call would not evalute anything.

How to design this function?
by ssqq
Sun Jun 15, 2014 3:47 pm
Forum: Anything else we might add?
Topic: in utf-8 mode regex return byte length
Replies: 2
Views: 4608

Re: in utf-8 mode regex return byte length

I make a function to get it. (define (get-utf8-index utf8-str byte-index) (letn ((str-lst (explode utf8-str)) (str-len (length str-lst)) (chop-lst (sequence (- str-len 1) 0)) (char-len-lst (map length str-lst))) (find byte-index (map (curry apply +) (map (curry chop char-len-lst) chop-lst))))) (get-...
by ssqq
Sun Jun 15, 2014 2:43 pm
Forum: Anything else we might add?
Topic: in utf-8 mode regex return byte length
Replies: 2
Views: 4608

in utf-8 mode regex return byte length

Code: Select all

> (length (char 0xff))
2
> (utf8len (char 0xff))
1
> (regex (char 0xff) (char 0xff))
("ÿ" 0 2)
> (regex (char 0xff) (char 0xff) 2048)
("ÿ" 0 2)
I think in UTF_8 mode, regex should return character location with utf-8 length.
by ssqq
Thu Jun 12, 2014 3:33 am
Forum: Anything else we might add?
Topic: load default functor Token-char:Token-char failed.
Replies: 2
Views: 4622

load default functor Token-char:Token-char failed.

I meet a strange problem: When I load the module with content below: (define Token-char:Token-char) (Token-char "key" 123) REPL output: ERR: context expected in function define : Token-char When I use other context name like: (define Token:Token) (Token "key" 123) That is ok. If have any reserved co...