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

Topics - TedWalther

#61
Hi, I'm using the amd64 (64 bit multicore) version of OpenBSD.  I compile newlisp with readline and UTF8 support using the stock bsd makefile and it seems to work, though I haven't done thorough testing.



I fixed the artful code and the default MySQL modules to load the correct library, and they can both open and close the database, making a connection, but doing a query and looking at the results gives it an instant segfault.  I suspect it has something to do with sizes of datatypes, perhaps even something to do with sql.c



Is anyone willing to log in and do some debugging?  What would you want per hour?



Is it possible I just need to compile and run sql.c to produce correct values for mysql5.lsp?



You can reach me at 778-320-0644 or user "tederific" on skype.





Ted
#62
how can I make read-file work with /dev/stdin?  when my application doesn't have a file specified by the user, I want to fall back to stdin to slurp my data in.  It is potentially utf8 data input, and I will want to iterate over each character in the stream..



Writing to /dev/stdout works just fine.



Perhaps the simplest solution is to let read-file etc use file descriptors (integers) as well as strings?



Example code:



(setq from-format (sym (or (env "FROM") "utf8")))

(setq   to-format (sym (or (env "TO") "neo-paleo-hebrew")))

(setq output-file (or (env "SAVEAS") "/dev/stdout"))

(setq  input-file (or (env "OPEN")   "/dev/stdin"))



(dostring (c (read-file input-file))

   (append-file output-file (char c)))
#63
I have a file full of lines like this:



Gen1:30 blah blah blah

2Pet3:4 blah blah blah



I want to extract that first word, and split it up as follows:



Gen1:30 becomes ("Gen" "1" "30")

2Pet3:4 becomes ("2Pet" "3" "4")



I've played with parse a bit, but I'm flummoxed on this one.



I've made some progress with this:



(parse ((parse str " ") 0) ":")



Which yields ("Gen1" "30")



Is this a job for (regex)?



UPDATE: I played with regex and got what I needed.



(regex {^(.[[:alpha:]]+)(d+):(d+)}) mystring)



Ted
#64
Anything else we might add? / quasiquote and gensym?
October 12, 2007, 01:46:30 AM
Lutz, are you planning to add a CL style quasiquote and unquote?  I notice back in 2004 someone tried to define it as a macro, but using qq and uq instead of the ` and , characters.



Also, will you be adding a gensym function?



Ted
#65
(setq foo "anbncn")

(indent foo "tt") => "ttanttbnttcn"



Hi guys.  I've been fiddling with "replace" and using regex functionality, but not sure how to make it do what I want above.



I want the start of every line to have some indent characters inserted, but if it ends with a newline, I don't want indent characters inserted after the last newline.  And there isn't a newline at the beginning of the string, but I want the indent characters there.  This is as close as I made it:



(replace "(^|n)" foo "\ntt" 0) => "\ntta\nttb\nttc\ntt"



Can someone show me what is the right way to define the "indent" function?  And if it was robust for various values of newline, such as nr, rn, and r, that would be great too. Empty lines don't need any indent characters added, which may make it easier.



Also, would it make sense for this (indent) function to be part of the base install?  Also, I am doing (constant 'cat append) to save typing when I want to join a bunch of strings; could that be made standard in subsequent release of newlisp as well?



Ted
#66
Hi.  I want to do something special with NewLISP.  I've been told that it is bad procedure, or almost impossible to do in other versions of LISP.



I want to integrate the Lilypond minilanguage into Newlisp.



I want to have a special function (lilypond ) and everything inside the brackets is interpreted differently.  The definition of "symbol" changes, etc.   I want newlisp to interpret it like this:



Take this:



(lilypond-notes

sacredHarpHeads set autoBeaming = ##f

        g2. d'2 d4 | d (c) b a2 g4 | a2. b | g2 g4 b2 a4 | b (c) d e2. | g d2 e4 | d (c) b a2. |b g2 g4 | d' (b) a b2.~ | b

)



And I want newlisp to treat it like this:



[text]

sacredHarpHeads set autoBeaming = ##f

        g2. d'2 d4 | d c b a2 g4 | a2. b | g2 g4 b2 a4 | b c d e2. | g d2 e4 | d (c) b a2. |b g2 g4 | d' (b) a b2.~ | b

[/text]



However, there is a difference.  I also want this to work:



(lilypond-notes g2. d'2 d4 | d c b (slur a b c))



should output



[text]g2. d'2 d4 | d c b (a b c)[/text]



That is, I want "slur" to be a macro that expands to something like (print (append "(" (lilypond-notes a b c) ")"))



And I want to be able to incorporate other lisp things in too.



So (lilypond-notes a b (tempo 60)) should output "a b tempo 60 4"  So the (tempo) function is just normal lisp, and symbols etc are interpreted as normal.



So I want to be able to have custom functions that interpret symbols differently, and still interleave and mingle functions of newlisp code.



Final example of what I want to do:



(define (tempo bpm) (push bpm *bpm*) (print "tempo " bpm "4"))



(lilypond-notes a'4 b2. (fermata c) d) should output this:



"a'4 b2." (tempo (/ (pop *bpm*) 2)) "fermata c" (tempo (* (pop *bpm*) 2)) "d"



and this would result in:



[text]

a'4 b2. tempo 40 4 fermata c tempo 80 4 d

[/text]



Any ideas how to do this?  This minilanguage would save a lot of typing, and associated typos, in the music typesetting work I do.



Ted