Re: Storing functions in the database
Hi Joh-Tob, > Reading the full 'doc helps. The solution was 'Any. > > : (rel body (+Any +Need)) > -> +Function Yes, almost. The +Need is wrong though, it is a prefix class and is at least not clean here. Also, as I always keep saying, be careful with +Need. It makes usually only sense for values which are initialized by the system at object-creation time. But if you absolutely want it, use (+Need +Any). ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Storing functions in the database
Problem solved. Reading the full 'doc helps. The solution was 'Any. : (pool "type.db") -> T : (class +Function +Entity) -> +Function : (rel name (+Idx +String)) -> +Function : (rel body (+Any +Need)) -> +Function : (new! '(+Function) 'name "fakultät" 'body '((N) (apply '* (range 1 N -> {2} : (new! '(+Function) 'name "sum2" 'body '((N X) (+ N X ))) -> {5} : (new! '(+Function) 'name "1-to-N-sum" 'body '((N) (/ (* N (inc N)) 2))) -> {6} : (select +Function) {6} (+Function) name "1-to-N-sum" body ((N) (/ (* N (inc N)) 2)) {2} (+Function) name "fakultät" body ((N) (apply '* (range 1 N))) {5} (+Function) name "sum2" body ((N X) (+ N X)) 2017-03-10 22:46 GMT+01:00 Joh-Tob Schäg : > Hello, > > i try to store a function is a database. Can somebody spot what i am doing > wrong? > > (pool "types.db") #empty > : (class +Function +Entity) > -> +Function > : (rel name (+Idx +String)) > -> +Function > : (rel body (+Bag +Bag +Need)) > -> +Function > ? (select +Function) > {5} (+Function) >name "1-to-N-sum" > > {2} (+Function) >name "fakultät" > > {6} (+Function) >name "sum2" > > -> NIL > ? (get {6} 'body) > -> NIL > ? (get {2} 'body) > -> NIL > ? (get {2} body) > -> NIL > ? (request '(+Function) 'body '((N X) (+ N X ))) #New Function with this > body is created because nothing found > -> {13} > ? (show {13}) > -> (+Function) > ? (request '(+Function) 'body '((N X) (+ N X ))) #New Function with this > body is created again! > -> {14} > > > > > >
Storing functions in the database
Hello, i try to store a function is a database. Can somebody spot what i am doing wrong? (pool "types.db") #empty : (class +Function +Entity) -> +Function : (rel name (+Idx +String)) -> +Function : (rel body (+Bag +Bag +Need)) -> +Function ? (select +Function) {5} (+Function) name "1-to-N-sum" {2} (+Function) name "fakultät" {6} (+Function) name "sum2" -> NIL ? (get {6} 'body) -> NIL ? (get {2} 'body) -> NIL ? (get {2} body) -> NIL ? (request '(+Function) 'body '((N X) (+ N X ))) #New Function with this body is created because nothing found -> {13} ? (show {13}) -> (+Function) ? (request '(+Function) 'body '((N X) (+ N X ))) #New Function with this body is created again! -> {14}