davv: The bluegreen quadruped. (Default)
[personal profile] davv
Oh dear, am I tired. (I made some pretty silly test mistakes a few weeks ago, also. Always read the questions in detail, folks![1])

I will say this, however: The functional programming I'm learning about (not what I had a test in) seems to be coloring my thoughts pretty significantly at the moment, because I used some of today's time wondering how to make a C-alike language that would support a more functional style... and I came up with odd syntax like

void foo(int x, int y) = { cout << x << ", " << y << endl; }

("And all functions are simply variables in the global scope") and

void bar() = {
    void foo(int a) = { return(a + 1); }

    int an_array[3] = {1, 2, 3};

    // increments every element in an_array by 1.
    imperative_map(an_array, foo, 3);

    for (int i = 0; i < 3; ++i) {
        cout << a_list[i] << endl;
    }
}


But there might be a language that does this already. Though to be powerful enough, this hypothetical C variant should also support type inference, so that higher order functions like imperative_map can work on any and all types. Either that, or it's typename<T> time!

Er, yeah.


[1] And most definitely don't just skim the question and read "a mapping from [1,2] x [1,3]" as "a mapping from [1,2] x [0,3]". That just won't do! Not to mention that on a multiple choice test, every wrong answer is equally wrong.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

March 2018

S M T W T F S
    123
45678910
1112131415 1617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Apr. 15th, 2026 11:13 pm
Powered by Dreamwidth Studios