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

#1
> (println [text]x)

~

ERR: missing end of text [/text]



ok in cli, however, not in .lsp file, try this

(println [text]

x)



or even this (forgot to type '/' in closing [/text])

(println [text]

x[text])



using (string) or (format  doesn't help either

(println (string [text]

         x))



(println (format [text]

         x))



top (on openbsd) shows a crawling but steady consumption of memory, eventually i get not enough memory error message
#2
> (date (date-value) 0 "%a %#d %b %Y")

"Sat #d Oct 2009"

> (date (date-value) 0 "%a %-d %b %Y")

"Sat -d Oct 2009"

> (date (date-value) 0 "%A %-d. %B %Y")

"Saturday -d. October 2009"



newlisp 10.1.5 on OpenBSD 4.5
#3
newLISP newS / (replace nil list-of-nil) hangs
May 17, 2009, 05:32:09 PM
> (set 'a '( 1 2))

(1 2)

> (replace 1 a)

(2)

> a

(2)

> (replace 2 a)

()

> a

()

> (set 'a '(true true))

(true true)

> (replace true a)

()

> (set 'a '(nil nil))

(nil nil)

> (replace nil a) ;hangs
#4
newLISP v.10.0.2 on Linux IPv4 UTF-8, execute 'newlisp -h' for more info.



> (set 'q '("m4" "08" nil "rs" "vr" "vt" "m4"))

("m4" "08" nil "rs" "vr" "vt" "m4")

> (unique q)

("m4" "08" nil "rs" "vr" "vt" "m4")   ;note "m4" appears twice

> (sort q)

("08" "m4" nil "m4" "rs" "vr" "vt")   ;note "m4" nil "m4"

> (replace nil q)

("08" "m4" "m4" "rs" "vr" "vt")

> (unique q)

("08" "m4" "rs" "vr" "vt")
#5
newLISP newS / newlisp: SMS CDMA
July 20, 2008, 10:33:11 AM
I'd like to share my brief experiment with CDMA venus VT-21 modem (TIAN TUO XIN DIAN CDMA Technologies) for sending SMS



the modem works under windows (98/xp  tested) and linux (unreliable driver tho)



;COM4 from system property or /dev/ttyACM0 from dmesg

(set 'o (open "COM4" "update"))

;sending sms to 12345678 -- don't forget the r

(write-buffer o "AT*MB*MOREQ=0,12345678,,4098,TEXT TO SMSr")

;checking inbox -- again, don't forget the r

(write-buffer o "AT*MB*READTI=R,4098r"

(read-buffer o 'INBOX 102400)

(save "INBOX" 'INBOX)



The AT commands unfortunately are proprietary and differ from modem to modem; worse, not all CDMA devices (cellphones especially) have AT commands



I haven't used the code with GSM modem/phones mainly because I do not know how to connect to bluetooth device using newlisp (linux doesn't assign a node in /dev/ and i haven't tried it in xp ... no driver);



for now, ubuntu gui bluetooth+gnokii are sufficient for my GSM need so i won't actively look for solution



If you know how to use newlisp to talk to bluetooth devices, please let me know.  I love newlisp and would like to see it used in more places



thanks!
#6
newLISP newS / list index out of bounds
March 05, 2008, 04:57:00 AM
can we have it graciously not to stop the running program?



personally i like the old way of returning the last element

it's because my program input can sometimes be an empty list (i have no control of my data source)



(set 'b '())

(b 0);program stops running

(b -1);progam stops running

(0 1 b);program stops running

(-1 1 b);proram stops running



i can put a condition of (if (= b '()) (do something)

but sometimes my input can be empty, one, or two elements

so my old codes of (input 2), (input 1), etc break

yes i can put conditions too

but that makes my program long and ugly

my past few weeks were of maintenance nightmare



my main gripe is that newlisp just stops running due to list index out of bound

it's like watching your favorite dvd and your software media player (being too smart) stops running due to a scratch

while the hardware dvd player (being dumb) just keep running the dvd till the end



sorry for my rants
#7
newLISP newS / slice negative counter
July 25, 2007, 04:17:48 AM
Hi all!



it's probably been discussed before but i haven't searched enough (i got the result on negative offset for slice)



is there any easy way to get negative counter act as position?

inclusive start and end

like:

(set 'a '(1 2 3 4 5 6 7))



(2 -2 a) ;want (3 4 5 6), newlisp gives (3 4 5 6 7)



in code:

(define (my-slice l s c)

   (if (>= c 0)

      (slice l s c)

      (slice l s (+ (length l) c -1))))



a; (1 2 3 4 5 6 7)

(my-slice a 2 -2) ;gives (3 4 5 6)

(my-slice a 2 0); gives ()

(my-slice a 2 2); gives (3 4)



it would be nice to have it in implicit slicing too like (2 -2 a)

thx!
#8
newLISP newS / matrix addition/subtraction/init
September 03, 2006, 02:14:58 AM
hi all



can we easily initialize a matrix by setting it to some array?

do we have matrix built-in function other than invert, multiply, transpose?

battery-included init, add, sub, determinant, size functions are nice to have



i played with matrix for a bit and i feel my code's long:



(set 'a (array-list (array 3 2 (sequence 1 6))))  ;matrix initialization

(set 'b (array-list (array 3 2 (sequence 4 9))))  ;array-list and array redundant?

(set 'c (array-list (array (length a) (length (a 1)) (map + (flat a) (flat b)))))

(invert (multiply (transpose c) c))

;((1.028645833 -0.8567708333) (-0.8567708333 0.7161458333))



this is my first time, sorry if the topic is old (i searched old posts tho)

thx!