So something like "tuck dup" can be rewritten as "xy-yxx". It's a lot easier to track what you're doing when you have long chains of stack manipulation.
Name:
Anonymous2007-07-25 13:59 ID:moFgDKky
"xy-yxyy"
fix'd
Goes to show that stack shuffling sucks.
Name:
Anonymous2007-07-25 14:10 ID:cSm+xp4k
>>17
reminds me of car/cdr/caar/cadr/cddr and some of the more exotic lisp macros
Name:
Anonymous2007-07-25 14:11 ID:cSm+xp4k
thread dup sage
Name:
Anonymous2007-07-25 17:03 ID:U1SdcRZy
Factor is halfway between Lisp and Brainfuck
Name:
Anonymous2007-07-25 17:12 ID:eFpIfUaa
>>15
perl? sub fib{my$n=pop,$f=5**.5;return+((1+$f)**$n-(1-$f)**$n)/($f*2**$n)} : fib ( n -- n ) 1 5 sqrt 3dup 3dup + swap ^ -roll - swap ^ -roll rot 2^ * * /;
look at that, it's only 10 characters shorter than it is in factor!
>>22
the factor version is actually shorter if you count tokens instead of characters.
Name:
Anonymous2007-07-27 13:41 ID:t7FojlNs
>>27
Whoops. I glanced at it and saw no sqrt and something that looked vaguely recursive.
What's with the + in "return+"?
Name:
Anonymous2007-07-27 19:38 ID:YSh9uO/z
lol wut, the simple haskell version is shorter than both perl and factor, and way more readable than both. actually it's not a haskell hack or anything, just the definition of the function, and i'm betting it looks the same in pretty much every language that's not retarded.
f n = ((1 + sqrt 5) ^^ n - (1 - sqrt 5) ^^ n) / ((2 ^^ n) * sqrt 5)
sub fib{my$n=pop,$f=5**.5;return+((1+$f)**$n-(1-$f)**$n)/($f*2**$n)}
and if you do the perl trick of skipping whitespace, it gets shorter
f n=((1+sqrt 5)^^n-(1-sqrt 5)^^n)/((2^^n)*sqrt 5)
and when you skip the whitespace...
(define(f n)(/(-(expt(+ 1(sqrt 5))n)(expt(- 1(sqrt 5))n))(sqrt 5)(expt 2 n)))
which is shorter than factor (and way way way more readable, unless you happen to think dup, swap, rot, tuck and nip are better than lotsa parenthesis)
btw, that shuffling macro seems interesting, I for instance can hardly remember what the functions do.
and way way way more readable, unless you happen to think dup, swap, rot, tuck and nip are better than lotsa parenthesis
you'd be surprised how many people do.
also, >>30-31 should count every pair of parentheses as a token.
if you're counting characters, that's just stupid. especially when comparing different languages.
Name:
Anonymous2007-07-27 20:18 ID:t7FojlNs
>>32
Whoa... those named unary operators seem like evil cruft. Why not just use parens properly? Did I miss something?
Name:
Anonymous2007-07-27 20:19 ID:YSh9uO/z
>>32
counting tokens is equally unuseful IMHO, because there is quite a difference in reading shuffling words and a single parenthesis. I think that the versions I proposed are superior (if we don't skip whitespace), because it's a mathematical function and they express it in a mathematical, succint way.
Yes, I know many people prefer dup swap rot tuck to ))))), but I still recon those versions I proposed are more readable.
Let's see in detail what happens:
- the ["\n"]c, group stores (,) in c a function whose only scope is emitting a new line ("\n")
- after the title (which is printed), the loop begins (in forth it would be a BEGIN WHILE REPEAT cycle)
- the two functions that manage this cycle are [%0>] (the control syntax sounds like "until the number on top of stack is positive") and [%.c@%2'2'+] (this is the actual algorithm for calculating Fibonacci numbers)
- the cycle is marked by the ! command
- the c@ sequence executes the function in c (new line)
- the 2' sequence is a ROT (namely a 2 ROLL in forth style)
- the symbol % is the DUP command
- the cycle stops when the number on TOS is negative (see the control function [%0>])
This program (actually a line) works on all systems that resolve an integer overflow as a negative number (e.g., for what about 32bit machines, my eMac G4 performs 2147483647 + 1 = -2147483648, which is a perfectly legal number).
That's Owl.
You've probably heard of Brainf**k.
Its author was inspired by a toy Forth called FALSE.
FALSE also inspired someone to with a similar toy Forth called Owl. It turns out there are a lot of people who get their kicks designing weird languages (Befunge, Bloop, etc.), and they play off each other's designs. There are several forks from FALSE, and some interesting apps written in FALSE as well.
BTW, the original FALSE was 1 page of Amiga assembler.
Some APL notes:
-It comes from math. The weird Greek symbols are favored by mathematicians writing formulas.
-Its author later wrote J, and APL users mostly switched to J.
-APL specializes in vectors: sorting, searching, merging, etc. When you step outside that problem domain, APL can be more trouble than help.
-Morgan Stanley wrote the A+ implementation of APL and offers it free. Vector math is useful in financial computing.
-The IOCCC 1989-robison program is a pico APL interpreter. No loops, but it does have functions and "indirection".
-Most full implementations have an interactive environment supporting individual function changes and fast development.
-dmoz has a category: http://dmoz.org/Computers/Programming/Languages/APL
The concept of divide and conquer in general It is as they say goto considered harmful my max gs print nDEATH n print The word was word n.
Name:
Anonymous2009-03-06 7:30
6f 6d 53 70 65 63 3d 43 3a 5c 43 55 44 41 5f 49.
Name:
Anonymous2009-03-06 11:52
C C has all the ones that picked it up and write the damn thing in C that you type in to debug and you put Do Nothing I think the compilers are removing support uh just!