newLISP doesn't use linked lists???
(I always secretly suspected Lutz was a C "source"-rer! ;O)
--xytroxon
Update: The "leg lifting" was continued by reddit HackerNews topic thieves.
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 MenuQuote
From: Roberto Ierusalimschy <roberto <at> inf.puc-rio.br>
Subject: Re: Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison
Newsgroups: gmane.comp.lang.lua.general
Date: 2013-07-15 17:24:28 GMT (4 hours and 17 minutes ago)
> Maybe this should be of interest:
>
>http://raid6.com.au/~onlyjob/posts/arena/">http://raid6.com.au/~onlyjob/posts/arena/
This test is ridiculous. Whoever wrote the code does not know how
to program in Lua (or in Java or in Javascript).
-- Roberto
Sudoku is probably the most popular puzzle nowadays. Lots of attempts have been made to solve Sudoku using programs. However, solving Sudoku is known to be an NP-complete problem, which means no efficient algorithm exists so far. Finding the solution largely relies on black magic. On the other hand, lacking a definite answer makes Sudoku more interesting. A variety of methods arise to solve Sudoku. Wiki gives a good brief view of the existing algorithms. I will focus more on the practical implementations.Quote
(new Tree 'pet-db)
(pet-db "dog" "King")
(pet-db "cat" "Fluffy")
(pet-db "hamster" "Sam")
(pet-db "fish" "Goldy")
(println "---> show the database")
(println (pet-db))
(println "--> list items")
; (dotree (pet pet-db) (println pet " -> " (pet) )) ; 1. Error?
; (dotree (pet pet-db true) (println pet " -> " (eval pet) )) ; 2, Hang and crash!
(dotree (pet pet-db) (println pet " -> " (eval pet) ))
(println "---> delete ttems")
; (dotree (pet pet-db) (println pet " -> " (pet nil) )) ; 1. Error?
; (dotree (pet pet-db true) (println pet " -> " ((prefix pet) (1 (string (term pet))) nil) )) ; 2. Hang and crash!
(dotree (pet pet-db) (println pet " -> " ((prefix pet) (1 (string (term pet))) nil) ))
(println "--> show database")
(println (pet-db))
(exit)
To summarize, this point of view about tail recursion is based on these ideas:Quote
* It's purpose is to avoid writing looping constructs, which are somehow considered 'bad' by 'purists'. These weirdos 'think' in loops, then transform the code to be 'recursive with tail calls' when they write it, and then expect the compiler transform it back. This is academic mental gymnastics with no practical purpose.
* People who like tail recursion are purposefully burdening their code in the name of 'mathematical' or 'theoretical' purity, but they expect the language implementor to bear the weight.
* Any code that depends on tail recursion can easily be rewritten to use a looping construct instead. Such a rewrite is a trivial local transformation.
* Inter-procedural tail recursion may have some performance benefit, but such benefit is very small at best, and the tradeoff is the loss of valuable debugging information.
GnuWin32 provides ports of tools with a GNU or similar open source license, to MS-Windows (Microsoft Windows 95 / 98 / ME / NT / 2000 / XP / 2003 / Vista / 2008)Quote
(context 'crypto)
; set library to path-name of the library on your platform OS
;
(set 'files '(
"C:/Program Files/gnuwin32/bin/libeay32.dll" ;<<< add this line
"/usr/lib/libcrypto.so"
"/usr/lib/libcrypto.so.0.9.8"
"/usr/lib/libcrypto.so.0.9.7"
"/usr/lib/libcrypto.so.0.9.6"
"/usr/lib/libcrypto.so.4"
"/usr/lib/libcrypto.dylib"
))
(setq in-my-text "this is useful")
(find "this" in-my-text)
(starts-with in-my-text "this")
(starts-with "this" in-my-text)
(starts-with (string in-my-text "xyz" (somestringfunc)) "this")
(starts-with "this" (string in-my-text "xyz" (somestringfunc)))
(replace "this" (string in-my-text "xyz" (somestringfunc)) "with that")
(replace "this" "with that" (string in-my-text "xyz" (somestringfunc)))
...The problem, of course, is that Arc lacks libraries. Arc lacks basic functionality such as fetching a web page, parsing an XML document, or accessing a database. Arc lacks utility libraries to parse HTML pages or perform numerical analysis. Arc lacks specialized API libraries to access sites such as del.icio.us or Akismet. Arc lacks specialized numerical libraries such as a support-vector machine implementation. (In fact, Arc doesn't even have all the functionality of TRS-80 BASIC, which is a pretty low bar. Arc is inexplicably lacking trig, exp, and log, not to mention arrays and decent error reporting.)Quote
To be sure, one could implement these libraries in Arc. The point is that implementing libraries detours you from the exploratory programming you're trying to do.Paul Graham has commented that libraries are becoming an increasingly important component of programming languages,that huge libraries are now an expected part of a new programming language, and that libraries are an increasing important feature of programming languages. Given this understanding of the importance of libraries, it's surprising that Arc is so lacking in libraries. (It's also surprising that it lacks a module system or some other way to package libraries.) It's a commonplace complaint about Lisp that it lacks libraries compared to other languages, and Arc makes this even worse...
;(Note: This entire code section can be copied to a file for testing.)
;
; Hi Lutz!
;
; I'm having a problem with the following console code
; using newLISP v.9.3.11 on Win32 IPv4
;
(print "Press <Enter> key to input name. ")
(setq key (read-key))
(println "Key pressed: " key)
(if (= key 13)
(begin
(print "Enter name: ")
(setq line (read-line))
(println line)
)
)
;
; Program output:
; ---------------------------------------------------------
; Press <Enter> to input name. Key pressed: 13
; Enter name:
; ---------------------------------------------------------
;
; Program continues without allowing line to be input.
;
; So let's try a different key...
;
(print "Press </> key to input name. ")
(setq key (read-key))
(println "Key pressed: " key)
(if (= key 47)
(begin
(print "Enter name: ")
(setq line (read-line))
(println line)
)
)
;
; Program output:
; ---------------------------------------------------------
; Press </> to input name. Key pressed: 47
; Enter name: /
; ---------------------------------------------------------
;
; This time it allows input, but prepends "/" to the input
; prompt. Typing in the name and pressing <Enter> is now
; allowed.
;
; ---------------------------------------------------------
; Enter name: /xytroxon <Enter>
; /xytroxon
; ---------------------------------------------------------
;
; Pressing <Backspace> will erase the extra "/". So the
; problem is that the (read-key) function is not consuming
; the key press and is carried over into (read-line)...
;
; -- xytroxon
(exit)
Quote
Given the supplied library classes write some code in "quickSilver" to convert between word and decimal digits representations of positive integers less than 1001.
e.g. "five seven three" → 573
e.g. 672 → "six seven two"
Quote
class WordsFromNumber:
def __init__(self,number):
self.representationOf = number
def wordsOf(self):
lsd = self.representationOf % 10
msds = self.representationOf / 10
if msds == 0:
return self.wordFor(self.representationOf)
else:
return WordsFromNumber(msds).wordsOf() + " " +
self.wordFor(lsd)
def wordFor(self,numeral):
return ["zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine"][numeral]
class NumberFromWords:
def __init__(self,words):
self.representation = words
def number(self):
words = split("\s",self.representation)
return self.unpack(words)
def unpack(self,words):
if len(words) == 1:
return self.numberFor(words[0])
else:
lswi = len(words) - 1
lswi = words[lswi]
msws = words[0:lswi]
return self.numberFor(lsw) + 10 * self.unpack(msw)
def numberFor(self,word):
return {"zero" : 0, "one" : 1, "two" : 2, "three" : 3,
"four" : 4, "five" : 5, "six" : 6, "seven" : 7,
"eight" : 8, "nine" : 9}[word]
From the newLISP FAQ:Quote
6. Does newLISP have hash tables?
newLISP has fast and scalable symbol processing using red-black binary trees . Symbols in newLISP are used to build dictionaries for associative data access, similar to how hash tables are used in other scripting languages. See the newLISP manual for more details.