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

#1
newLISP in the real world / Re: (newbie) Listiness
October 25, 2014, 08:53:49 PM
I'm sure there are Newlispers here who will be able to provide a much better solution (probably with just a single function), but nonetheless perhaps some of the following might spawn some ideas for you.



-----------------

> (set 'in-string (read-file "tmp/foo.tmp"))

"# stuff to ignoren123]

> (set 'all-lines (parse in-string "n"))

("# stuff to ignore" "123]

> (set 'non-empty-lines (clean = all-lines)) ; monadic = compares to empty string

("# stuff to ignore" "123]

> (define (comment? s) (starts-with s "#"))

> (set 'lines (clean comment? non-empty-lines))

("123]

> (define (split-at-colons s) (parse s ":"))

> (set 'contents (map split-at-colons lines))

(("123" "avc") ("234" "vvc") ("999" "xxc"))
#2
Whither newLISP? / Re: A pair of lists
April 29, 2013, 04:38:17 AM
Quote from: "cormullion"Do you mean '((a b c) (10 20 30))?


Functionally the pair of lists would be equivalent to '((abc) . (10 20 30)) but when printed, the dotted notation gets removed such that the items in the second list directly follow the first list.



"Indexed list" would still seem a fairly apt term.
#3
Whither newLISP? / A pair of lists
April 28, 2013, 09:21:06 PM
I am writing a tutorial on developing a Scheme compiler and one of the data structures I am using is a pair of lists, where the car of the pair is a list of the symbols and the cdr of the pair is a list of their values.



For example, an a-list of the data might be '((a . 10) (b . 20) (c . 30))

And the p-list version would be '((a 10) (b 20) (c 30))

My data structure would be '((a b c) 10 20 30)



I am wondering if there is a common name for such a data structure (along the lines of a-list and p-list). If not, I would be open to suggestions on how I should refer to it.
#4
newLISP newS / LispNYC holding Lisp project contest
April 09, 2013, 05:18:21 AM
LispNYC is holding a contest for programmers, artists, and creators who use or create things with Lisp.



It is open to all Lisp-type programming languages: Common Lisp, Scheme, Clojure, and "any recognized dialect of Lisp". I would assume that newLISP qualifies. Registration starts on June 1st.



http://lispinsmallprojects.org/welcome">//http://lispinsmallprojects.org/welcome
#5
Quote from: "cormullion"(write-file input-file (join lines "n"))

Aha, join was the function I was missing. I have always been fond of the strbreakup and unbreakupstr functionality of http://www.cs.indiana.edu/scheme-repository/imp/siod.html">SIOD and GIMP's Script-fu interpreter, and the fact that Newlisp offers this with parse and join is a definite plus.
#6
You are overwriting the characters that follow "CLOUD_ENGINE_HOME=".



You may have to split your file into lines and then replace the entire line.



For example (note: I do not do much Newlisp coding so there is probably a better way):
#!/usr/bin/newlisp
(set 'filename (main-args 2))
(set 'entire-file (read-file filename))
(set 'lines (parse entire-file "n"))
(replace "CLOUD_ENGINE_HOME=" lines "CLOUD_ENGINE_HOME=/opt/cloud_engine_home")
(device (open filename "write"))
(while lines
  (println (pop lines)) )
(close (device))
(exit)
#7
Quote from: "gatesphere"I've traced it, and found that after a (sum 4), sum => (lambda ((x 0)) (inc 4 x))...  this confuses me.

Consider the syntax diagram for how the expression "(inc 0 x)" might be stored in memory.



http://www.kerosenecow.net/data/images/misc/inc-ast.png">



The 'inc' primitive, when invoked with its first argument being a literal number, apparently behaves by updating the memory cell of that atomic number (represented in the diagram by the oval containing a blue "0"). If the expression, "(inc 0 x)" is evaluated by itself on the command line, the "0" cell is updated but then destroyed when the function is completed (in Scheme the cell would be released for later garbage collecting, but my understanding is that Newlisp does not produce such garbage).



However, since in your example "(inc 0 x)" is contained within the lambda definition of 'sum', the "0" cell (indeed the entire lambda expression) persists in memory. So when you execute "(sum 4)", the "0" cell is updated to contain "4", which continues to persist within the definition of 'sum'.



That would be my characterization of what is occurring -- the "magic" of the function modifying itself takes place inherently within the execution of 'inc', not through any explicit manipulation of the
#8
Numeric constants that start with a zero are http://en.wikibooks.org/wiki/Introduction_to_newLISP/Working_with_numbers">treated as octal numbers, therefore '8' and '9' are not valid digits.
#9
newLISP and the O.S. / Re: Vector Linux
June 02, 2012, 02:48:37 PM
The problem you are encountering with libffi stems from Slackware and is described in http://www.linuxquestions.org/questions/slackware-14/guile-upgrade-dependency-problems-884879/">this thread on LinuxQuestions.org.



Basically, the Slackware package for gcc-java includes a version of libffi -- but it does not include the pkgconfig or header files (http://www.linuxquestions.org/questions/slackware-14/finally-gimp-2-8-a-943103/page2.html#post4671080">Robby Workman considers this a mistake and states that libffi will be shipped as a separate package in the next Slackware).



I have found that installing the http://slackbuilds.org/repository/12.2/libraries/libffi/">libffi SlackBuild from Slackware 12.2 was sufficient for most of my ffi needs, though you might want to edit the script to build a more recent version. I do not know whether this approach would interfere with gcc-java as I do not use Java.
#10
My speculation is that the problem is arising from the way Apache's mod_write handles parsing (assuming you are using mod_rewrite). Guile developer Andy Wingo offers a good description of this http://wingolog.org/archives/2010/12/23/doing-it-wrong">on his weblog.