🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2763

Re: On whether C has first-class composable functions

#2763
From: Douglas E. Quale
Date: Mon, 11 Feb 1991 16:20
37 lines
2071 bytes
In article <6828:Feb906:14:3491@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes:
>I never said that those expressions were nonsensical. Your implication
>is a lie, plain and simple. I doubt you have the integrity to review the
>articles and apologize, but I'll give you one chance to do so before I
>start quoting things in public.
>

Quote away, Dan.  I'm not afraid of the truth.

>> Instead of continually saying it's trivial, post your compose code in C and
>> then we'll see how it stacks up.
>
>I did. Since you apparently would rather flame than think, here's the
>three-way composition that you claim to be so difficult. I've written it
>out step-by-step and put in comments just for you.
>
>  compose(square,square,sqsq) /* put square o square in sqsq */
>  compose(square,sqsq,sqsqsq) /* put square o sqsq in sqsqsq */
>  printf("%d\n",apply(sqsqsq,2)); /* apply sqsqsq to 2 and print it */
>
>Exercise: write the missing struct fun definitions and initializations.
>
>---Dan

Dan, this is your job, not mine.  I say it can't be done.

int square(int i) { return i*i; }

is easy enough, but I can't get the rest to work.
I keep getting a type clash in the second call to compose, since your
compose takes function pointers as arguments (I used &square)
and returns a structure.  Unfortunately square and sqsq don't have
the same types (both should be functions).

How about helping me out?

-- Doug Quale
Technical Details
Message-ID: <1991Feb11.162041.9889@spool.cs.wisc.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!julius.cs.uiuc.edu!wuarchive!uwm.edu!uwvax!picard.cs.wisc.edu!quale
References: <25199:Feb801:33:1191@kramden.acf.nyu.edu> <1991Feb8.191014.6430@spool.cs.wisc.edu> <6828:Feb906:14:3491@kramden.acf.nyu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!julius.cs.uiuc.edu!wuarchive!uwm.edu!uwvax!picard.cs.wisc.edu!quale
From: quale@picard.cs.wisc.edu (Douglas E. Quale)
Newsgroups: comp.lang.misc
Subject: Re: On whether C has first-class composable functions
Message-ID: <1991Feb11.162041.9889@spool.cs.wisc.edu>
Date: 11 Feb 91 16:20:41 GMT
References: <25199:Feb801:33:1191@kramden.acf.nyu.edu> <1991Feb8.191014.6430@spool.cs.wisc.edu> <6828:Feb906:14:3491@kramden.acf.nyu.edu>
Sender: news@spool.cs.wisc.edu (The News)
Organization: U of Wisconsin CS Dept
Lines: 37