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

#1
newLISP Graphics & Sound / graphic file
July 13, 2011, 08:56:08 PM
Is there a way to open graphic file in newLisp? For example jpeg or gif file? I understand that there is a way to import C libs, but libjpeg, for example, includes work with pointers and I don't know how to make it possible in newLisp.
#2
Thank you fro the answers, that solved the problem.
#3
It doesn't work with passed values.
(set 'x '(0 1 2 '(3 4)))
(define (destruct lst) (setf (lst 3 0) 1))
(destruct x)
-> 1


This won't change the variable.
#4
I have a few questions about destructive functions. Can anybody explain why setf doesn't work with passed values ? It may return correct value, but it doesn't change the variable itself.



PS maybe it would be better if I describe full problem:

I need to edit branches or / and leafs inside a tree. I wanted to pas the branch as a parameter to my changing function, and process it with destructive pop and push functions, but it doesn't work. Is there a right way to do this?
#5
newLISP in the real world / Re: Objects
March 06, 2011, 11:16:54 AM
Thanks for good answers.
#6
newLISP in the real world / Re: Objects
March 06, 2011, 12:53:21 AM
Quote from: "Sammo"A direct translation of the Scheme code to newLisp might be:


; make-square
; 2011-03-05
; example
; (set 's1 (make-square 2))
; (s1 'area) ;result = 4
; (s1 'perimeter) ;result = 8
; (s1 'xxx) ;result = "unknown message" error
(define (make-square side)
(letex (s side)
(lambda (msg)
(cond
((= msg 'area) (mul s s))
((= msg 'perimeter) (mul 4 s))
(true (throw-error "unknown message")) ))))



Thanks for translation. Can you explain why we need letex in this case? Why lambda can't take side from function definition?
#7
newLISP in the real world / Re: Objects
March 06, 2011, 12:45:52 AM
Thanks for the answers. I read about FOOP. Simply this lambda conception looked interesting for me.
#8
newLISP in the real world / [solved] OOP
March 05, 2011, 01:55:14 PM
I found an interesting piece of code in scheme, but I failed to make it work in newLisp. Can anybody explain why?


(define (make-square side)
   (lambda (msg)
    (cond ((eq? msg 'area) (* side side))
      ((eq? msg 'perimeter) (* 4 side))
      (else (error "unknown message")))))

> (define s1 (make-square 4))
> (s1 'area)
> 16