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

#1
I got similar problems on Window 7: my settings directory contained russian letters and was therefore unvisible for newlisp-edit. There was an error:



ERR: problem saving in function save: "C:\Users\241232233232\Appdata\Roaming/newlisp/newlisp-edit.config"



So I have added these strings into newlisp-edit.lsp to circumvent the problem:


(set 'userSettingsDir "c:/TEMP")
(set 'userSettingsPath (append userSettingsDir "/newlisp-edit.config"))
(set 'recentFilesPath (append userSettingsDir "/newlisp-edit-recent"))


Now I can enjoy newLISP on my Windows 7.
#2
newLISP and the O.S. / Re: NewLISP and CentOS
July 21, 2010, 04:53:37 AM
Thank you, installed successfully. If anybody else will try to repeat:



wget http://www.newlisp.org/downloads/newlisp-10.2.8.tgz">http://www.newlisp.org/downloads/newlisp-10.2.8.tgz

tar -xf newlisp-10.2.8.tgz

cd newlisp-10.2.8

sudo ./configure-alt

sudo make

sudo make install
#3
newLISP and the O.S. / NewLISP and CentOS
July 20, 2010, 10:57:34 AM
I got a virtual server with CentOS installed: now I need to run my newLISP projects on it.



Is it possible to install newLISP somehow via yum or any other automatic manager?



Or I should download sources and compile newLISP manually?
#4
Thank you! This method is much faster: 0,4 seconds vs 3 seconds with "filter" method.



So now I can load one hundred price-lists per second, so my task is accomplished.
#5
newLISP in the real world / How to reduce a list?
July 03, 2010, 07:52:20 AM
I have a list like this:


'((1 Oil 2)
  (1 Oil 5)
  (1 Oil 7)
  (2 Gas 4)
  (2 Gas 12))


I want to reduce it and get list like this:


'((1 Oil 2 5 7)
  (2 Gas 4 12))


I can make it via "ref" or "find" or "filter" operators, but list is pretty big (3'000 records), so speed is important for me.



It takes about 3-4 seconds to reduce list on my PC, but I want 0.5 seconds or even less. May be, there is a special operator for list reducing in newLISP?
#7
I`m used to join "find-all" and "replace" operators via $it/$0 symbol:


(find-all "12" "12345" (replace "1" (copy $0) "N"))

But now, after upgrading to 10.2.8, newLISP says:



"ERR: symbol is protected : $0"



Is here a way to make this construction to work, or I`ll have to change my code somehow to avoid $0/$it symbols?
#8
Quote from: "Robert Gorenc"do you have same success in writing to serial port?


Yep. Here is a part of working code (Windows PC):


; Initialization
(define (scales-init)
  (exec "mode COM1 BAUD=9600 PARITY=N DATA=8 STOP=1"))

; Getting data from COM-port
(define (scales-weight-up)
  (local (hndl buff)
    (set 'hndl (open "COM1" "r"))
    (read hndl buff 40 (char 0x0D))
    (close hndl)
    (int (-12 5 buff))))

(scales-init)

; Measuring
(if (catch (scales-weight-up) 'result)
  (println "Weight: " result)
  (println "No link."))
#9
newLISP in the real world / Re: Web Crawler
April 17, 2010, 02:02:47 AM
Quote from: "kanen"Has anyone written a web crawler in newLISP?


I have written later in 2009 some kind of crawler to gather information from one big goverment site.



Pretty simple thing, just several hundreds lines of code, "cgi.lsp" + regular expressions + lots of cookie romp. If you are going to make crawler without cookie, I think, simple crawler can be developed in one evening.
#10
As far as I can see, we will not be able to locate two different strings (empty and non-empty) at the same offset.


(find-all "((?<=FILE:)[0-9]*)|(sample.gif)" "FILE:sample.gif")

But, probably, there will be no such situations in real life.
#11
Quote from: "Lutz"Unfortunately this strategy will swallow legitimate empty strings


Yep, I have made an error: I did not took into account difference between starting search position and actual offset of the found item:


(set 'offset 0 'lst '())
(while (set 'offset (find {(^|(?<=,))("(([^"]|"")*)"|([^",]*))}
  {Ten Thousand,10000, 2710 ,,,,,,,"10,000","It's ""10 Grand"", baby",10K} 0 offset))
  (set 'offset (+ offset (length $0)))
  (if (and lst (= (list offset $0) (last lst)))
    (inc offset)
    (push (list offset $0) lst -1)))

(silent
  (println "--- Found: " (length lst) " ---")
  (map println lst))
#12
I guess additional check for zero-length will help:


(set 'offset 0 'lst '())
(while (set 'pos (find {(^|(?<=,))("(([^"]|"")*)"|([^",]*))}
  {Ten Thousand,10000, 2710 ,,"10,000","It's ""10 Grand"", baby",10K} 0 offset ))
  (if (and lst (= (last lst) $0 ""))
    (inc offset)
    (begin
      (set 'offset (+ offset (length $0)))
      (push $0 lst -1))))


As far as I know, there is a metacharacter G in the Perl:



"G  Match only where previous m//g left off (works only with /g)"



I have no experience with PCRE standarts, but, may be, there are some preset rules — how should search engine process empty strings?
#13
Here is an example from Friddle`s book:


(find-all {(^|(?<=,))("(([^"]|"")*)"|([^",]*))}
 {Ten Thousand,10000, 2710 ,,"10,000","It's ""10 Grand"", baby",10K})


It will be very hard to make parse operator to process quotes correctly. And I can not just ignore empty fields, becouse their place is important. (I use some complex regexp when parsing data in csv, rtf etc).



However, it is not too important. I can just replace ",," to the ",_empty_," before applying find-all.
#14
For some reason find-all operator stops on empty strings:


> (find-all "(?<=,)[^,]*(?=,)" ",1,10,,100,1000,")
("1" "10" "")


I did expect here:


("1" "10" "" "100" "1000")

I think, somewhere inside find-all operator is a check: (if (= found-string prev-string) stop-search)



Is it a feature to make programmers use "parse" operator for empty string searching?
#15
Quote from: "Cyril"(import "iconv.dll" "libiconv")


GIMP iconv.dll made this for me! Thanx!