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

#16
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))
#17
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.

#18
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
#19
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?
#20
Hi guys,



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



the following code returns nil for utf-8 character

(regex {w} "č")

and so the following

(regex {w} "č" "u")

while this works

(regex {w} "m")



Is this not implemented or am I doing something wrong?

VT
#23
Please could you write more on newLISP use cases in your company? I found this very interesting.
#24
Anything else we might add? / Re: TLS/SSL support
October 23, 2016, 01:29:02 AM
Optionally of course. There are already optional parts as UTF-8 support or FFI so why not TLS if bigger binary is not a problem.
#25
Anything else we might add? / Re: TLS/SSL support
October 22, 2016, 03:14:53 AM
Thank you for replies guys. I also started using curl, but IMHO whole world has started using https protocol so soon or later get-url against public internet will be useless.
#26
Hi guys,



how can I map trim command to list members?

say I have list like this:
(set 'lst '("a." "b " "c"))
and I want to trim dot character trying this construct:
(set 'lst2 (map (curry trim {.}) lst))
but it doesn't work, output is:
("." "." ".")
#27
Anything else we might add? / Re: TLS/SSL support
October 14, 2016, 10:43:08 AM
Sorry I mean support in get-url function to receive data from site which uses https.
#28
You are right. This is one of the things I love on Golang, and now on newlisp as I'm a novice :)
#29
Anything else we might add? / TLS/SSL support
October 13, 2016, 09:51:21 AM
Hi guys,



is there a chance that newlisp will support TLS/SSL in the near future? In my case I need it to fetch content using httpS protocol.



VT