@heyandy889 I mostly agree with you. However, a function by definition returns a value or object. A subroutine doesn't. As it turns out, all functions and methods in Python return the object 'None', if no explicit 'return' statement is used within the function or method to return something. So in Python terms, they are the same thing. The intention of my comment was to highlight the semantic difference between both, within the realms of imperative and object orientated language paradigms.
@JeremyNasmith min() returns the minimum value from a list/set, yes. The code is short, but it is far from efficient. Python takes the niceties out of having to traverse arrays/lists by hiding all the real work from the coder (when you call min() on a list, it's having to go away and call a lengthy subroutine to work this out). Based on the data structures Python uses to store lists/sets etc, this will normally be pretty fast, most times. As for Lambda functions, Google is your friend.
a.sort() is not a function, it is a method which operates on list objects. But I appreciate what you are saying about a.sort() being in-line. My attempt at sorting a list without using in-built Python sort (non in-line) is this (yes, it is the most naive sorting algorithm but it works): def my_remove(l,v): l.remove(v) return l my_sort = lambda l: l and [min(l)] + my_sort(my_remove(l,min(l))) my_sort([7,3,5,9,3,5,45,1,3,764745,42354,3]) [1, 3, 3, 3, 3, 5, 5, 7, 9, 45, 42354, 764745]
@parkamark Nice concise code: but for us noobs: what is lambda in python? And I suppose min(l) returns the smallest/first value in list l? if min works this way, it's a very nice solution for having to traverse the list, and remember progressively smaller encountered values...
@AkrionXxarr My comments are in relation to Python, not C/C++. Interestingly, you have written, and I quote, 'a function of type void doesn't return anything' - well, it does, doesn't it? It returns an object, of type 'void'. Python returns objects of type 'None'. WikiPedia: 'The void type, in several programming languages derived from C and Algol68, is the type for the result of a function that returns normally, but does not provide a result value to its caller.' ... ???