Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
July 23, 2013 How to call a function in main()? | ||||
---|---|---|---|---|
| ||||
I am new to programming. my function is look like "T[] sort(T)(T[] A) {}". What is main() look like to use the function? If you know sites about dealing with syntax, please leave the links. Thanks. |
July 23, 2013 Re: How to call a function in main()? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jaehunt | Jaehunt: > I am new to programming. D is a large language, it will take lot of work and time to learn it. > my function is look like "T[] sort(T)(T[] A) {}". > > What is main() look like to use the function? Take a look at the RosettaCode site, it contains hundreds of small D programs of many different kinds, including an answer to your question: http://rosettacode.org/wiki/Insertion_sort#D Bye, bearophile |
July 23, 2013 Re: How to call a function in main()? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Tuesday, 23 July 2013 at 22:27:40 UTC, bearophile wrote:
> Jaehunt:
>
>> I am new to programming.
>
> D is a large language, it will take lot of work and time to learn it.
>
>
>> my function is look like "T[] sort(T)(T[] A) {}".
>>
>> What is main() look like to use the function?
>
> Take a look at the RosettaCode site, it contains hundreds of small D programs of many different kinds, including an answer to your question:
>
> http://rosettacode.org/wiki/Insertion_sort#D
>
> Bye,
> bearophile
Thank you for your advice and links.
I mean when function has "T[]" in the front, how am I calling it?
Thanks
|
July 23, 2013 Re: How to call a function in main()? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jaehunt | On Tuesday, 23 July 2013 at 22:39:20 UTC, Jaehunt wrote:
> On Tuesday, 23 July 2013 at 22:27:40 UTC, bearophile wrote:
>> Jaehunt:
>>
>>> I am new to programming.
>>
>> D is a large language, it will take lot of work and time to learn it.
>>
>>
>>> my function is look like "T[] sort(T)(T[] A) {}".
>>>
>>> What is main() look like to use the function?
>>
>> Take a look at the RosettaCode site, it contains hundreds of small D programs of many different kinds, including an answer to your question:
>>
>> http://rosettacode.org/wiki/Insertion_sort#D
>>
>> Bye,
>> bearophile
>
> Thank you for your advice and links.
>
> I mean when function has "T[]" in the front, how am I calling it?
>
> Thanks
I got it, Thanks.
|
July 23, 2013 Re: How to call a function in main()? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jaehunt | Jaehunt:
> I mean when function has "T[]" in the front, how am I calling it?
If it's a sorting routine, then it probably sorts data in-place, so it's more clear to not return data. If the function copies inside the input data before sorting it, then it's right to return the result.
That's why in Python sort returns nothing and sorted() returns data.
The D sort finds a third way, returning something that is not exactly the input data :-)
Bye,
bearophile
|
Copyright © 1999-2021 by the D Language Foundation