* currying
@ 2010-09-06 19:36 Eric J. Van der Velden
2010-09-07 15:07 ` currying Thien-Thi Nguyen
2010-09-07 20:20 ` currying Andy Wingo
0 siblings, 2 replies; 3+ messages in thread
From: Eric J. Van der Velden @ 2010-09-06 19:36 UTC (permalink / raw)
To: guile-user
[-- Attachment #1: Type: text/plain, Size: 884 bytes --]
Hello,
1.
I have curried (compose) so that I can define (not2) below,
(define compose(lambda(f)
(lambda(g)
(lambda(x)
(f(g x))))))
(define not2
(compose not)
)
((not2 null?)'())
This is OK.
2.
I do this also,
(define both(lambda(f)
(lambda(a b)
(and(f a)(f b))
)
))
(define neithernull
(both ((compose not)null?) )
)
(neither '()'())
This is OK.
3.
But both here below are ERR,
(define neither
(both ((compose not)) )
(define neither
(both (compose not))
The first one doesn't compile. The second one does, but this is not what I
meant; It suspects two arguments, the '() '() for example , instead of one,
the funtion null? for example.
Can I define (neither) is some way that I can do something like
((neither null?)'(a)'(a))
Thanks,
Eric J.
[-- Attachment #2: Type: text/html, Size: 1098 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: currying
2010-09-06 19:36 currying Eric J. Van der Velden
@ 2010-09-07 15:07 ` Thien-Thi Nguyen
2010-09-07 20:20 ` currying Andy Wingo
1 sibling, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2010-09-07 15:07 UTC (permalink / raw)
To: Eric J. Van der Velden; +Cc: guile-user
() "Eric J. Van der Velden" <ericjvandervelden@gmail.com>
() Mon, 6 Sep 2010 21:36:58 +0200
(define neither
(both (compose not))
The first one doesn't compile. The second one does, but this is
not what I meant; It suspects two arguments, the '() '() for
example, instead of one, the funtion null? for example.
Can I define (neither) is some way that I can do something like
((neither null?)'(a)'(a))
Presuming that you'd like this expression to have value #t, try:
(define neither
(lambda (p?)
(both ((compose not) p?))))
aka
(define (neither p?)
(both ((compose not) p?)))
Style nit: i somewhat dislike the one-arg ‘compose’. IMHO, the
procedure most befitting that name should take any number of args,
including zero. That complicates the implementation, but such is
life on the edge of the knife...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: currying
2010-09-06 19:36 currying Eric J. Van der Velden
2010-09-07 15:07 ` currying Thien-Thi Nguyen
@ 2010-09-07 20:20 ` Andy Wingo
1 sibling, 0 replies; 3+ messages in thread
From: Andy Wingo @ 2010-09-07 20:20 UTC (permalink / raw)
To: Eric J. Van der Velden; +Cc: guile-user
Hi Eric,
Your code is not formatted idiomatically. If you want feedback, use
standard style.
Lacking anything Guile-specific, I think Taylor Campbell's style guide
is as fine as any:
http://mumble.net/~campbell/scheme/style.txt
Cheers,
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-09-07 20:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-06 19:36 currying Eric J. Van der Velden
2010-09-07 15:07 ` currying Thien-Thi Nguyen
2010-09-07 20:20 ` currying Andy Wingo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).