Search found 66 matches

by fdb
Sat Sep 13, 2014 11:05 pm
Forum: newLISP and the O.S.
Topic: Calling OBJC runtime from newlisp
Replies: 19
Views: 18613

Re: Calling OBJC runtime from newlisp

Solved the returning of a struct (struct 'Point "double" "double") (struct 'Rect "point" "point") (import "/System/Library/Frameworks/Foundation.framework/Foundation" "NSRectFromString" "Rect" "void*") So you can define the struct as a return type, was not mentioned in the documentation for import ,...
by fdb
Thu Sep 11, 2014 8:05 pm
Forum: newLISP and the O.S.
Topic: Calling OBJC runtime from newlisp
Replies: 19
Views: 18613

Re: Calling OBJC runtime from newlisp

Hi Ted, you're right NSRecFromString is expecting an NSString, copied the wring line but (NSRectFromString (NSString "stringWithUTF8String:" "100,100,100,100")) doesn't work either. I think it is because it is returning a struct by value and in the import function you cannot define that it returns a...
by fdb
Tue Sep 09, 2014 9:11 pm
Forum: newLISP and the O.S.
Topic: Calling OBJC runtime from newlisp
Replies: 19
Views: 18613

Re: Calling OBJC runtime from newlisp

I'm having problems with a function which returns a struct. To make a window appear on the screen i need an NSRect type, which is defined as a struct: {{CGFloat,CGFloat},{CGFloat,CGFloat}}. I've imported this function: (import "/System/Library/Frameworks/Foundation.framework/Foundation" "NSRectFromS...
by fdb
Tue Sep 02, 2014 3:16 pm
Forum: newLISP and the O.S.
Topic: Calling OBJC runtime from newlisp
Replies: 19
Views: 18613

Re: Callig OBJC runtime from newlisp

Ok, got the basic machinery working to send messages to classes and instances, see below. Next step is to use callbacks for setting delegate's so you could populate a table view from newLISP. ;;Objective-c bridge (import "/System/Library/Frameworks/Foundation.framework/Foundation") (set 'get-class (...
by fdb
Sun Aug 31, 2014 5:19 pm
Forum: newLISP and the O.S.
Topic: Calling OBJC runtime from newlisp
Replies: 19
Views: 18613

Re: Callig OBJC runtime from newlisp

Ok, to answer my own question ;-) > (import "/System/Library/Frameworks/Foundation.framework/Foundation") true > (get-class "NSString") 140735249161920 Is anyone interested in an newlisp-OBJC bridge? An obvious advantage would be the ability to make native MAC GUI applications, and maybe even IOS ap...
by fdb
Sun Aug 31, 2014 11:01 am
Forum: newLISP and the O.S.
Topic: Calling OBJC runtime from newlisp
Replies: 19
Views: 18613

Re: Callig OBJC runtime from newlisp

Was probably wrong to use a literal string but this also doesn't work:

Code: Select all

> (set 'nsstring "NSString") 
"NSString"
> (get-class nsstring)
0
> 
by fdb
Sun Aug 31, 2014 10:40 am
Forum: newLISP and the O.S.
Topic: Calling OBJC runtime from newlisp
Replies: 19
Views: 18613

Calling OBJC runtime from newlisp

I'm trying to call the objc runtime from new lisp (from mac osx10.9) but i've got a problem: > (set 'get-class (import "libobjc.dylib" "objc_getClass" "void*" "char*")) objc_getClass@7FFF9391BF70 > (get-class "NSString") 0 What am i doing wrong here? I was expecting a pointer to the NSString class. ...
by fdb
Sun May 04, 2014 5:04 pm
Forum: Anything else we might add?
Topic: array literal and Tail Call Optimization
Replies: 3
Views: 4479

Re: array literal and Tail Call Optimization

Hi ssqq, For the second part of your question have a look at the code patterns of newLisp http://www.newlisp.org/downloads/CodePatterns.html#toc-5 how you can speed up things with iteration or memorisation, a memoised fibonacci on my laptop takes 0.014 microseconds with an argument of 100. ; speed u...
by fdb
Tue Apr 29, 2014 7:19 pm
Forum: newLISP in the real world
Topic: strange result with map and apply
Replies: 7
Views: 4544

Re: strange result with map and apply

Thx! I understood the function from bairui directly (why didn't i think of that..) but i had to look in the documentation to understand cormullion's solution and then i saw in the documentation this example: (set-ref-all '(oranges *) data (list (first $it) (apply + (rest $it))) match) .... Great doc...
by fdb
Mon Apr 28, 2014 9:49 pm
Forum: newLISP in the real world
Topic: strange result with map and apply
Replies: 7
Views: 4544

Re: strange result with map and apply

Thanks a lot bairui and Luts! Hadn't used curry before. Another question i just encountered is how to change all items in a list in one go, for example: (set-ref-all "2" '(("1" "2" "3") ("4")) (int $it)) (("1" 2 "3") ("4")) Works but i want to change all the strings to integers in one go but couldn'...
by fdb
Sat Apr 26, 2014 9:57 pm
Forum: newLISP in the real world
Topic: strange result with map and apply
Replies: 7
Views: 4544

strange result with map and apply

Code: Select all

> (map (apply +) '((0 1 2) (3 4 5)))
((0 1 2) (3 4 5))
> (map (fn(x) (apply + x)) '((0 1 2) (3 4 5)))
(3 12)
Why doesn't the first example work?
by fdb
Mon Dec 23, 2013 1:05 am
Forum: newLISP Graphics & Sound
Topic: How to delete rows,columns and table's?
Replies: 7
Views: 8823

Re: How to delete rows,columns and table's?

Hi , i've added the ability to delete rows and columns in a table in a build i made in 10.5.4 I have added the following methods to Dispatcher.java: methods.put("table-remove-row", "tableRemoveRow"); //deleting of a row methods.put("table-set-column-name", "tableSetColumnIdentifiers");//add/delete/u...
by fdb
Tue Dec 17, 2013 9:20 pm
Forum: newLISP Graphics & Sound
Topic: How to delete rows,columns and table's?
Replies: 7
Views: 8823

Re: How to delete rows,columns and table's?

Great! Are you also planning to add the ability to delete rows and columns? At the moment i dispose the frame and then recalc and recreate the frame , which doesn't matter too much because i have to recalc all the tables (6) anyway but it does of course means flickering.
by fdb
Tue Dec 17, 2013 6:04 pm
Forum: newLISP Graphics & Sound
Topic: How to delete rows,columns and table's?
Replies: 7
Views: 8823

Re: How to delete rows,columns and table's?

Thx for the reply, i'll dispose the frame and rebuilt it after i've recalculated the UI. I also saw there seemed to be no option to have a table without column headers, but you can actually achieve this with an empty string "" as the column header so (gs:table 'row-table 'gs:no-action "" "") will gi...
by fdb
Mon Dec 16, 2013 10:00 pm
Forum: newLISP Graphics & Sound
Topic: How to delete rows,columns and table's?
Replies: 7
Views: 8823

How to delete rows,columns and table's?

How can i delete rows and/or columns in a gs:table? there seems to be only the option to add them..or am i missing something? Furthermore i cannot delete a gs:table when i try to do so with gs:dispose i get the message
dispose cannot be applied to MAIN:row-table
by fdb
Sat Nov 09, 2013 9:34 pm
Forum: newLISP in the real world
Topic: Thousand's separator
Replies: 9
Views: 4667

Re: Thousand's separator

One-liner: (define (format1000 n) (append (sgn n "-" "" "") (reverse (join (explode (reverse (string (abs n))) 3) ",")))) (format1000 123456789) (format1000 -123456789) Excellent! I'm new to new lisp (love it!) but this doesn't work for numbers with a decimal part. My try: (define (format1000 n) (l...