# Tag Info

55

It's called banker's rounding. The idea is to minimize the cumulative error from many rounding operations. Lets say you always rounded .5 down. Think of all those little interest payments, the bank pocketing half a cent each time... Lets say you always rounded .5 up. Accounting is going to scream because you're paying out more interest than you should.

43

Is LISP still practiced/used in todays world, or is it a legacy language Yes, it is, but you have to know where to look. People who use LISP don't tend to shout too loudly about it but there's a handful of examples of a few high-profile startups having used it to great effect over the last 20 years. It is also very popular with small companies in Europe. ...

39

A while ago I constructed a test program for successive rounding, because it's basically a worst-case stress test for a rounding algorithm. For each number from 0 to 9,999 it first rounds to the nearest 10, then to the nearest 100, then to the nearest 1000. (You could also think of this as 10,000 points in [0,1) being rounded to 3 places, then to 2, then to ...

29

Many Lispers will tell you that what makes Lisp special is homoiconicity, which means that the code's syntax is represented using the same data structures as other data. For example, here's a simple function (using Scheme syntax) for calculating the hypotenuse of a right-angled triangle with the given side lengths: (define (hypot x y) (sqrt (+ (square x) (...

23

A dissenting opinion: Lisp's homoiconicity is far less of a useful thing than most Lisp fans would have you believe. To understand syntactic macros, it's important to understand compilers. The job of a compiler is to turn human-readable code into executable code. From a very high-level perspective, this has two overall phases: parsing and code generation....

22

The following annotation in the Framework Design Guidelines Section 3.3. Names of Assemblies and Dlls offers insight into why namespaces and assemblies are separate. BRAD ABRAMS Early in the design of the CLR we decided to seperate the developer view of the platform (namespaces) from the packaging and deployment view of the platform (assemblies). This ...

21

If there is no assignment statement,how can this be done?How to change the balance variable? You can't change variables without some sort of assignment operator. I ask so because I know there are some so-called pure functional languages out there and according to the Turing complete theory,this must can be done too. Not quite. If a language is Turing ...

18

I mostly use macros for adding time-saving new language constructs, that would otherwise require a bunch of boilerplate code. For example, I recently found myself wanting an imperative for-loop similar to C++/Java. However, being a functional language, Clojure didn't come with one out of the box. So I just implemented it as a macro: (defmacro for-loop [[...

18

Short Answer: There is a simple solution to your problem. Just install the virtual-machine with Linux (Ubuntu) - it is free. I am also a mainly .NET developer who loves to experiment different things, or try variety of frameworks and/or development tools. The main thing here is not to mess your main development environment. Thus, installing everything in a ...

17

Queues don't functionally compose, and are difficult to implement in a well-performing way without making them mutable. The very nature of a queue suggests that you put things into it and take things out of it, which is at odds with the immutable nature of functional languages. Oh, sure, you can do the same thing with lists, but generally what you are ...

15

Take a look at this posting by Matthias Felleisen to the LL1 discuss list in 2002. He suggests three main uses for macros: Data sublanguages: I can write simple-looking expressions and create complex nested lists/arrays/tables with quote, unquote, etc. neatly dressed up with macros. Binding constructs: I can introduce new binding constructs with ...

14

In my first year at the university the first programming course I took was using SICP (that was 1988). However, I had a similar problem like you: for my own computer (actually a Commodore Amiga), there was no Scheme implementation available at that time, only a different Lisp dialect (I don't remember its name). However, given the flexibility of Lisp, it ...

13

What sorts of things do people actually end up doing with macros? Writing language extensions or DSL's. To get a feel for this in Lisp-like languages, study Racket, which has several language variants: Typed Racket, R6RS, and Datalog. See also the Boo language, which gives you access to the compiler pipeline for the specific purpose of creating Domain-...

13

Denotational design (program design rooted in and flowing from denotational semantics) is my primary methodology. A few years ago while writing about FRP, I got much clearer about what I'd been doing. See Push-pull functional reactive programming. For a more explicit description of the paradigm and a variety of examples, see Denotational design with type ...

13

How do you propose the head be reached in this reversed list? If not using mutable structures the reversed list would only be performant if you made the head linear time and tail constant. But now you've got the exact same structure as before except you're calling the head the tail and vice versa. the structure is the way it is because regardless of which ...

12

I use Haskell and Scala (and also doing some Scheme, Common Lisp, SML, OCaml, Erlang) all under Linux (Ubuntu). All of the above languages (compilers and interpreters) can be installed quite easily (there are packages that can be installed using apt-get or another package management system). Scala has a good integration with Eclipse and the Scala plugin(s) ...

12

Quote Quote returns data which you should not modify, and which may share structure between themselves. E.g. if you have a file which contains (define l1 '(1 2 3)) (define l2 '(4 2 3)) then the compiler is permitted to allocate l1 and l2 in a way that they share their common tail (cdr l1) and (cdr l2) and/or in the read-only memory. Modification of such ...

12

Well, the other answers cover what \() -> "something" means in Haskell: an unary function that takes () as argument. What is a function without arguments? – A value. Actually, it can occasionally be useful to think of variables as nullary functions that evaluate to their value. The let-syntax for a function without arguments (which doesn't actually exist)...

11

You're right that it looks a lot like a method on an object. That's because that's essentially what it is. The lambda function is a closure that pulls the external variable balance into its scope. Having multiple closures that close over the same external variable(s) and having multiple methods on the same object are two different abstractions for doing ...

10

MacOS requires Mac hardware or you might get it to run on VirtualBox, but last time I tried that it didn't work. And since you don't want to replace your current configuration/setup problems with other problems, I suggest you either spend a lot of money or try linux. I've used Ubuntu for Haskell, Scala and Lisp development with Eclipse, Netbeans, IntelliJ ...

10

In that section of the book, filter, map, and enumerate-interval are presumed to return sequences, which are conceptually distinct from lists. You can implement sequences using streams, for example, though you can implement sequences using lists too. So, in this case, the accumulate with cons is to convert the sequence to a list.

9

Wait until you'll get to the lexical closures. Than try to grasp the homoiconic property of the language - this is what makes it really different from the C-likes. And make sure you'll learn a Scheme with a proper define-macro implementation (I'd recommend Racket or Bigloo), not just standard hygienic macros (the latter would not surprise you at all if you'...

9

There's no dotted pair in Clojure. A philosophical reason for this is that Clojure avoids the use of a concrete "pair" data structure and instead emphasises abstract "sequences" which can have may possible concrete implementations. The closest equivalents are list and cons: ;; construct a sequence by consing a value onto any sequential object (here a ...

9

Frege says in "Funktion und Begriff" (1891): Wie nun Funktionen von Gegenständen grundverschieden sind, so sind auch Funktionen, deren Argumente Funktionen sind und sein müssen, grundverschieden von Funktionen, deren Argumente Gegenstände sind und nichts anderes sein können. Diese nenne ich Funktionen erster, jene Funktionen zweiter Stufe. In ...

9

Maybe an objective (if indirect) measure would be useful here. Consider the sizes of the specifications for the languages. Racket is basically an implementation of R6RS Scheme. The R6RS specification is 90 pages long, total. Of that, about 25 pages are devoted to the language proper, and about 30 more are devoted to its standard library. Along with that, ...

9

I'm not so sure I believe these people. I've gone through SICP and the biggest blocker you'll run into is how call-with-current-continuation (call/cc) is implemented. While MIT-Scheme is officially endorsed, there are a few downsides to MIT-Scheme Old Unmaintained as far as I can tell Pretty mediocre environment/repl Not so great errors On the other hand ...

8

If you want to learn Lisp today, I'd have a look at either racket, which is a fast scheme implementation (well, it actually departed a little from scheme, so it is its own dialect now) or clojure, which benefits from the JVM it runs on (so gazillions of libraries are available, plus you can make it interact with your own Java code). Even if you don't learn ...

8

Generally, programming language specifications are not very good tutorials. They are worded so as to be prescriptive rather than descriptive, although I think the best specifications identify discrete, separable requirements in simple, disjoint shall statements that are pretty easy to evaluate, and are further documented with a description and an example. ...

8

Further to ratchet freak's comment, look up discriminated union, or tagged union. You can make your data type a void *, but you also need to track what it really points to. That is, at some point you need to figure out if it's an integer or a double or another list. The tagged union itself might look something like this: #include <stdlib.h> #include ...

8

You're misinterpreting what () means in Haskell. It isn't the lack of a value, it is rather the only value of the Unit type (the type itself being referred to by an empty set of parentheses ()). Since lambdas can be constructed to use pattern matching, the lambda expression \() -> "s" is explicitly saying "create an anonymous function, expecting an input ...

Only top voted, non community-wiki answers of a minimum length are eligible