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

#1
this whole case is weird, i suppose no one replied to greg. no one knows what's with Lutz who really owns and runs newlisp.org domain and web site now because it was even down for a while, who runs this forum etc. :(



Please don't take me wrong I assume that Lutz is in state in which he is unable to exist in this community anymore whatever this state is. I would consider to take

code, rename language to elimininate lisp flamewars and trolls (name it eg. Lutz) buy appropriate domain to run website and forum and create some small github community around official repo. I'm not C programmer, but I'm ready to contribute with some money to help this happen.



It is so sad for me even some people consider newlisp mature and done.
#2
Sad :(
#3
Joining this thread to support Kirill's prayers :) https et al. is everywhere now.
#4
newLISP in the real world / Uploading multiple files.
February 18, 2018, 01:56:40 PM
Hello guys,



I tried upload.cgi example and it works for me, but what if I need to upload multiple files at once? I can't figure out how to do this. Are there multiple file boundaries in POST data than? Also there is no reference to <input type=file /> name in upload.cgi. It is not needed because we are checking for boundary and than it doesn't matter?
#5
newLISP in the real world / VIM indent
October 30, 2017, 01:50:22 PM
Hello guys,



is someone using Vim to edit newlisp code? I can't get it to use 4 spaces autoindent. It uses only single space.

Can someone help me?
#6
Hi guys,



is it possible to get line number which is currently executed in script? Somethin like:



(if error  (println $lineno))
;; something magical like $it :)

Thanks in advance.
#7
newLISP in the real world / Re: set - setf - setq woes
August 22, 2017, 07:35:27 AM
Description in manual is short and simple

http://www.newlisp.org/downloads/newlisp_manual.html#setf">//http://www.newlisp.org/downloads/newlisp_manual.html#setf
#8
Hi guys,

is it possible to set hash items at once in hash definition?



;; this works
(define cities:cities)
(cities "ny" "new york")
(cities "sf" "san francisco")
(println (cities "sf"))

;; this not
(define cities:cities '(
    ("ny" "new york")
    ("sf" "san francisco")))

(println (cities "sf"))
#9
Thanks for your version rickyboy. Things happen when I don't know the language enough. Knowing replace can use regexp one can avoid find-all :) Cool.
#10
Hello, rickyboy.



Thank you for your long answer. I like the "curry" trick :) I still don't know/use all newlisp goodies. I'm playing with newlisp http server and I wanted to use such a function in my html view templates, this is why function prints by default. Now it looks cleaner for me than println/string combinations.



<%
(dolist (m lst)
    (p {<div class="member"><b>:m:</b></div>}))
%>


For now, inspired by you, I changed the function definition so you can choose if you want printing or returning. It is solved with additional argument "ret"



(define (P str (ret nil) (sep ":"))
    (set 'fields '())
    (find-all (format {%s([a-z0-9-]+)%s} sep sep) str (push $1 fields -1))
    (dolist (f fields)
        (if (set 'val (eval (sym f MAIN nil)))
            (replace (string sep f sep) str (string val))))
    (if (not ret)
        (println str)
        str))
#11
newLISP in the real world / Re: String interpolation
August 01, 2017, 01:36:52 AM
I'm new in (new)lisp, if someone can optimize it I would be glad.



(set 'name "John" 'age 37 'city "NY")

;; P replaces symbol name in string with its value, symbol name is enclosed
;; between colons (or choose your own), symbol must be defined
(define (P str (sep ":"))
    (set 'fields '())
    (find-all (format {%s([a-z0-9-]+)%s} sep sep) str (push $1 fields -1))
    (dolist (f fields)
        (if (set 'val (eval (sym f MAIN nil)))
            (replace (string sep f sep) str (string val))))
    (println str))

;; default call
(P ":name: lives in :city: and is :age: years old.")
;; -> John lives in NY and is 37 years old

;; custom separator
(P "!name! lives in !city! and is !age! years old." "!")
;; John lives in NY and is 37 years old.

;; custom separator, one symbol undefined
(P "~name~ lives in ~city~ and is ~blah~ years old." "~")
;; -> John lives in NY and is ~blah~ years old.

#12
OK. It's like placeholders in function format but named so

instead of %s you are using named placeholders

The effect should be like in PHP where you write something like this

$one = 1;

$two = 2;

$str = "here $one and there $two";



So instead of

(println (format "here %d and there %d" one two))

one can use

(myprintln "here :one: and there :two:")



(set 'one 1)
(set 'two 2)
(set 'str "here :one: and there :two:")
(set 'placeholders '())
(find-all {:([a-z]+):} str (push $1 placeholders -1))
(dolist (p placeholders)
    ;; pseudo
    replace string p in str with value of symbol of the same name if it exists
    in this case replace word "one" with 1 and word "two" with 2
(println str) # -> here 1 and there 2
#13
Hello guys,



is there some way how to replace placeholders in string with symbols values?

"value of one is :one: and value of two is :two:"

I want to replace :one: and :two: with values of symbols 'one and 'two if they exists. How to get symbol value if its name is available as string?
#14
Hi guys,



is it possible to achieve something like this in newLISP?
(assign name city age '("john", "new york", 22))
#15
So there is no way how to match this character as a word character using pattern?