 |
 |
|
 |
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 10:31:32
Message: <493fe0d4$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>> Something about dozens of parenthesis...
>
> Most of it are procedure calls and would need parentheses in most
> languages anyway. At least, no colons between parameters are needed. ;)
Bah! And people complain because Haskell allows you to write simple
expressions with no punctuation at all... :-P
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 10:32:56
Message: <493fe128$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>> (if (= 1 x) (lambda (n) (1)) (lambda (n) (+ 1 n)))
>
> I don't really think someone scripting Gimp needs lambdas.
You would *hope* not...
(OTOH, does the GIMP allow you to use arbitrary lambda functions for
tone mapping? That could be useful!)
> Actually, the "if-then-else" statement was born in Lisp.
Really? You have proof of that?
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 10:37:14
Message: <493fe22a@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible escreveu:
>> Actually, the "if-then-else" statement was born in Lisp.
>
> Really? You have proof of that?
http://en.wikipedia.org/wiki/Lisp_(programming_language)#Language_innovations
Not that wikipedia is authorithative knowledge... :P
Until then, all you had was assembly branching.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Mike Raiford
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 10:57:11
Message: <493fe6d7@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> Most of it are procedure calls and would need parentheses in most
> languages anyway. At least, no colons between parameters are needed. ;)
Not so much that, but rather the deep nesting that gets to me..
--
~Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 10:59:51
Message: <493fe777$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>> Most of it are procedure calls and would need parentheses in most
>> languages anyway. At least, no colons between parameters are needed. ;)
>
> Not so much that, but rather the deep nesting that gets to me..
This is why Haskell allows you to take
foo1(foo2(foo3(foo4(foo5(foo6(x))))))
and rewrite it as
foo1 $ foo2 $ foo3 $ foo4 $ foo5 $ foo6 x
;-)
(Otherwise, you'd need a special editor which counts the number of
brackets for you to make sure they actually match up!)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:07:48
Message: <493fe954$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Hmm... let's see that in visuals...
foo(1, 2, 3, 4, 5, 6, 7, 8);
Lisp:
(foo 1 2 3 4 5 6 7 8)
Haskell:
foo 1 2 3 4 5 6 7 8
...and the award for fewest characters required to express a simple idea
goes to: Haskell. ;-)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:18:48
Message: <493febe8@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible escreveu:
>> Not so much that, but rather the deep nesting that gets to me..
You can break down in separate procedures/functions if you prefer. But
deep nesting with anonymous functions is a hallmark of functional
languages...
> This is why Haskell allows you to take
>
> foo1(foo2(foo3(foo4(foo5(foo6(x))))))
>
> and rewrite it as
>
> foo1 $ foo2 $ foo3 $ foo4 $ foo5 $ foo6 x
Haven't we gone through this before?
(define (compose f g . fs)
(if (null? fs) (lambda (x) (f (g x)))
(apply compose (lambda (x) (f (g x))) (car fs) (cdr fs))))
(define o compose)
(define (inc n) (+ 1 n))
(define (sqr n) (* n n))
(o inc sqr inc) ; returns a procedure, which you may store somewhere and
later reuse
((o inc sqr inc) 3) ; applies the procedure to argument 3
so, you're example would be:
((o foo1 foo2 foo3 foo4 foo5 foo6) x)
foo1 $ foo2 $ foo3 $ foo4 $ foo5 $ foo6 x
whoa! It's shorter! ;)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Darren New
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:21:18
Message: <493fec7e$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
nemesis wrote:
> (o inc sqr inc)
This level of notation, without the parens, is where I always get lost
trying to understand SML. The presence of parens shows what's an argument
and what's a function, in ways that mixing binary and unary operators that
are spelled the same way as variables doesn't.
--
Darren New, San Diego CA, USA (PST)
The NFL should go international. I'd pay to
see the Detroit Lions vs the Roman Catholics.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:25:39
Message: <493fed83@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible escreveu:
> Lisp:
> (foo 1 2 3 4 5 6 7 8)
>
> Haskell:
> foo 1 2 3 4 5 6 7 8
>
>
> ...and the award for fewest characters required to express a simple idea
> goes to: Haskell. ;-)
Actually, that example should be perfect for Python/Ruby and their's
named arguments. 8 friggin' arguments is impossible to remember which
is which! They beat both Haskell and Lisp hands down... :)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: GIMP hotkeys/ scripts/ user-defined functions?
Date: 10 Dec 2008 11:27:18
Message: <493fede6@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>>> Not so much that, but rather the deep nesting that gets to me..
>
> You can break down in separate procedures/functions if you prefer. But
> deep nesting with anonymous functions is a hallmark of functional
> languages...
I would say that if you find yourself needing to nest things *too*
deeply, you're doing something wrong.
>> This is why Haskell allows you to take
>>
>> foo1(foo2(foo3(foo4(foo5(foo6(x))))))
>>
>> and rewrite it as
>>
>> foo1 $ foo2 $ foo3 $ foo4 $ foo5 $ foo6 x
>
> Haven't we gone through this before?
>
> (define (compose f g . fs)
> (if (null? fs) (lambda (x) (f (g x)))
> (apply compose (lambda (x) (f (g x))) (car fs) (cdr fs))))
>
> (define o compose)
>
> (define (inc n) (+ 1 n))
> (define (sqr n) (* n n))
>
> (o inc sqr inc) ; returns a procedure, which you may store somewhere and
> later reuse
>
> ((o inc sqr inc) 3) ; applies the procedure to argument 3
>
> so, you're example would be:
>
> ((o foo1 foo2 foo3 foo4 foo5 foo6) x)
> foo1 $ foo2 $ foo3 $ foo4 $ foo5 $ foo6 x
>
> whoa! It's shorter! ;)
What, defining three pages of code is longer than the 1-liner I posted?
The ($) operator is defined in the Haskell language standard. :-P
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |