2

接受函数为参数,返回值为函数

I can vaguely translate this as

Gets function as parameter, return value is function.

but that's only due to my domain knowledge. I am confused by the use of 为 here. The only 为 I know is when I want to say for someone or something such as

汉语水平考试是一个考试为了外国人。(HSK is a test for foreigners) - I am not quite sure if it's grammatically correct to append 为 at the very end as such.

2
  • 为 has two pronunciations and quite a lot of meanings ... Have you tried a dictionary?
    – fefe
    Jul 30, 2018 at 3:58
  • @fefe For sure I have, but as you have mentioned, it does come with quite a lot of meanings that are hard to distinguish because of the subtleties they each carry. For example, 为 can mean become or for. These meanings can all fit into that sentence without much problem and I hope you get what I mean. I want a native point of view. I also wanted to test out my previous understanding of 为 and see if it's correct. Jul 30, 2018 at 4:06

3 Answers 3

3

接受函数为参数,返回值为函数

Your translation is quite right. The sentence seems to be a description of a function; which takes a function as the parameter, and its return value is a function too.

To be more precise, the first means

(充当) serve as; act as; play the part of:

call a stag a horse;
指鹿为马
This will serve as a proof.
以此为凭。

The 2nd 为 means

(是) be; mean:

One kilometre is equivalent to two li.
1公里为2华里。
One hundred centimetres make one metre.
100厘米为一米。

为 in 汉语水平考试是一个考试为了外国人 (especially used as 为了) is used for describing the purpose.

介词
(表示目的):

work hard for realizing the four modernizations;
为实现四个现代化而努力工作
write for a living
为生活而写作

BTW: The correct syntax should be 汉语水平考试是一个为了外国人的考试; because 为了外国人 is the modifier of 考试 so it should be put before of 考试 (i.e. the object). More naturally you can say 汉语水平考试是一个面向外国人的考试. Because 为了外国人 is broad and then might be confusing, the specific purpose is hard to get.

3
  • Thank you. As for 汉语水平考试是一个考试为了外国人 is it incorrect because object and verb modifiers cannot both at the same time come after the verb of the sentence? For example, in this case the verb would be 是 and object is 考试, and 为了外国人 would be the modifier so a grammatically correct one would be 汉语水平考试是一个为了外国人的考试? Jul 30, 2018 at 4:14
  • @金允雄Oliver You got the point Jul 30, 2018 at 4:17
  • 1
    @金允雄Oliver Yes. 为了外国人 is the modifier of 考试 so it should be put before of 考试 (i.e. the object).
    – user4072
    Jul 30, 2018 at 4:18
0

To Augment the other answer: 为 is a verb when it's pronounced as wéi, and a prep as wèi.

You interpreted 为 as "is" in this context is fine. However, your translation does have some issues:

接受函数为参数,返回值为函数: Gets function as parameter, return value is function.

First, 接受函数 as a noun phrase should be translated as acceptance function unless you meant "gets" in "gets function" is a nominal usage(but I figure you meant it's a verb "get".). Second, you need some articles a or the in your English sentence.

So the whole translation can be:

The acceptance function is the parameter, and the return value is a function.

3
  • What is acceptance function in the point view of programming?
    – user4072
    Jul 30, 2018 at 5:28
  • @songyuanyao, I figure from the limited context it means the function is used for the acceptance/receive purpose. So, 接受函数为参数 means it takes the whole 接受函数 as its parameter.
    – dan
    Jul 30, 2018 at 5:38
  • 2
    Yes I think the text is limited to the programming context, it's used to describe a function; which takes a function as its parameter, and return value is a function too. Parsing the sentence in this way seems more natural.
    – user4072
    Jul 30, 2018 at 5:41
0

接受函数为参数,means the accepted/gotten function is parametar, and the returned value is function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.