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

#16
Quote(map inc '(1 2 3 4 5))

  but above expression returned a list? or a quoted list?


It returns an unevaluated list:


(2 3 4 5)

As does:


'(1 2 3 4)
(1 2 3 4)


which is why you can do:


(map inc (map inc '(1 2 3 4))
;-> (3 4 5 6)


I don't think built-in functions are exactly macros, but many of them have special behaviour: e.g. if fortunately does not evaluate all the expressions passed to it. If it did, programming would be very difficult...
#17
Hi there. The wikibooks was intended as a general and gentle introduction, perhaps for people such as  engineers or non-programmers who want to introduce some automation to their work. This mirrors newLISP itself, which is similarly not directed purely towards computer science graduates and experienced  programmers, who find it lacking in some key areas. If you're an experienced programmer, you should find the Code Patterns and Reference Manual more than sufficient to get started.



You shouldn't confuse or compare newLISP and Common Lisp. The two languages share common ancestors but are very different in both large and small ways. My recommendation is to play with newLISP and see if you like Lisp programming. Your choices then range from Common Lisp, Scheme, Clojure, and many more besides.
#18
Not sure, I don't think it does. Of course you can easily say:


(dolist (x b) (dolist (y a) (push (list x y) results -1)))

but presumably this isn't a list comprehension, just a nested list iteration. Although I glanced through the Wikipedia entry and the Rosetta code examples, I didn't get the concept... Do you have any examples that couldn't be simply written as list iteration?
#19
Also in the manual:



"Several options can be combined using a binary or | (pipe) operator. E.g. (| 1 4) would combine options 1 and 4."
#20
I think you've done the right thing by asking Jeremy for help... :) Although it sounds like an Apache/file permissions thing, rather than newLISP.
#21
Some previous posts:



http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=5&t=4131&hilit=tail+call">//http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=5&t=4131&hilit=tail+call



http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=15&t=2748&hilit=tail+call">//http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=15&t=2748&hilit=tail+call



http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=5&t=4131&hilit=tail+call">//http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=5&t=4131&hilit=tail+call



http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=12&t=4319&hilit=tail+call">//http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=12&t=4319&hilit=tail+call
#22
Don't forget to use + - * /  % rather than add sub mul div mod for integers...



If you find any errors or can add suggestions http://en.wikibooks.org/wiki/Introduction_to_newLISP/Working_with_numbers">//http://en.wikibooks.org/wiki/Introduction_to_newLISP/Working_with_numbers, please do! :)
#23
I don't think pow is big-integer friendly - has (pow 9 17) already exceeded 64-bit integer range and converted to float?



The addition of bigint into newLISP is very recent, and at the moment I don't think all arithmetic operations can handle them. newLISP isn't designed to be as maths-aware a language as some others, and you'll need to be careful how you switch between int, float, and bigint...
#24
How about:


(set-ref-all '(*) '(("1" "2" "3") ("4")) (map int $it) match)
;-> ((1 2 3) (4))


I admit that match is the one area in newLISP that I always fail to get right in the first few attempts... :)
#25
:)



The plan was to get the newLISP syntax into the linguist code, but even with help I can't get my pull request past the "Travis build" phase. I have no idea what Github are doing (busy watching hula-hooping work colleagues?) but they couldn't have made it more difficult .... I think we'll just have to make do with labelling ourselves as Common Lisp users for now... I can cope with the shame. :)
#26
Ah, so it was the self-ish additions that were wrong... Good job, mate! (I assume, I can't run the code...)
#27
Perhaps someone with mySQL installed can help - I tried to run mysql.lsp on my Mac but mysql isn't installed by default. I stick to sqlite :).



newLISP itself changes quite often - - but there are many libraries out there which don't manage to keep up with the changes....



On another thread, Lutz offers this advice for moving from old FOOP to new FOOP - this may not be relevant, but here it is:


; old FOOP code original
(define (method obj p1 p2)
   ...
   (... (obj 1) ...)
)

; old FOOP code prepared for upgrade
(define (method self p1 p2)
   ...
   (... (self 1) ...)
)

; new FOOP code after taking out self from the parameter list
(define (method p1 p2)
   ...
   (... (self 1) ...)
)
#28
Some suggestions - I don't actually know the answer...:)



If you're using the latest version from Github, that appears to be written for an earlier newLISP version - 10.0.1... It's possible that the change in FOOP (in version 10.2?) has made the code non-functional.



I'm not sure whether these code modules have been updated recently. Looking at the various dates, I expect not. Also, I think Jeff and Kanen have moved on to other things. So someone needs to fix and maintain them.
#29
newLISP in the real world / Re: regex \\d{n} problem
March 22, 2014, 03:27:10 AM
@bairui yes, their power is undisputed. Beauty? Well, in a way, perhaps. But the reason I hate them is because they make me feel stupid. :) I can write a pattern which works, but when I look at it later I can't understand it at all, and I can't read it fluently. (Have a look at https://github.com/cormullion/newlisp-projects/blob/master/markdown.lsp">markdown.lsp. I can't help feeling there's a better way.)
#30
newLISP in the real world / Re: regex \\d{n} problem
March 21, 2014, 10:48:59 AM
(replace "[^a-z]" "@$@&i&&@&$@h$$a@@&%&@%t@@%@%@e%%&@@$r@$%%e&&%&g@%%u$&&%l&@a&%$r@$%e@%x%&p&r&@$@e&$&ss&$i%&o%%%@ns"{}0)