Yeah is it just due to my blind dedication to C++, or is Scheme...ugly?
Yeah is it just due to my blind dedication to C++, or is Scheme...ugly?
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
It takes some getting used to, but it can be surprisingly easy to work with compared to C syntax. There's relatively little syntax in Scheme compared to C++, so it's good to learn as a beginner's functional language.
Scheme is not my favorite language i prefer C or Java...
Scheme syntax is much more readable than C syntax. It doesn't help (a) that he didn't use code tags, and (b) if you don't use Scheme much.
This doesn't look like Scheme to me. At least it isn't revision 5. What is this from?(local [(define myvar 0)]
This is correct syntax in DrScheme, which is what I've been using for the past term. There's probably a few differences from the standard, I'll admit.
I worked with Common Lisp for a bit, but I couldn't befriend the syntax - although I have to admit, it's a very powerful language.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
scheme looks better in code tags and with a bracket matching editor such as DrSchemeYeah is it just due to my blind dedication to C++, or is Scheme...ugly?
This snippet reverses a list recursively. For instance,Code:(define (nested-reverse l) (cond ((null? l) '()) ((list? (car l)) (append (nested-reverse (cdr l)) (list (nested-reverse (car l))))) (else (append (nested-reverse (cdr l)) (list (car l))))))
Code:(nested-reverse '(a b (c d (e f) (g h) i) j k)) would return (k j (i (h g) (f e) d c) b a)
If you don't like the syntax of Scheme, you could always try Haskell. It has order of operations and infix operators (gasp!). The most beautiful language out there, if you ask me.Originally Posted by JaWiB
Factorial function definition:
Of course, you get to stomach things like infinite-length lists. An infinite-length list of numbers 1,2,3,...Code:factorial 0 = 1 factorial n = n * factorial (n - 1)
Code:positives = repeatup 1 where repeatup n = n : repeatup (n + 1)
Scheme and Haskell are quite different. Scheme is still fundamentally an imperative language, although it has quite a few functional elements. Haskell is a pure functional language. It requires a different mindset to program in.
And why so complicated on the 1,2,3... thing?
Code:positives = [1..]
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law