standard-library

What is Scalas Product.productIterator supposed to do?

萝らか妹 提交于 2019-12-05 03:27:04
Can someone tell me why I am getting different results when using Tuple2[List,List] and List[List] as my Product in the code below? Specifically I would like to know why the second value of the list of lists gets wrapped in another list? scala> val a = List(1,2,3) a: List[Int] = List(1, 2, 3) scala> val b = List(4,5,6) b: List[Int] = List(4, 5, 6) scala> val c = List(a,b) c: List[List[Int]] = List(List(1, 2, 3), List(4, 5, 6)) scala> c.productIterator.foreach( println(_) ) List(1, 2, 3) List(List(4, 5, 6)) // <-- Note this scala> val d = (a,b) d: (List[Int], List[Int]) = (List(1, 2, 3),List(4,

Compile a static library link with standard library (static)

≡放荡痞女 提交于 2019-12-05 01:37:04
问题 I'm trying to compile a static library (let's call it library.a). This library consumes resources of standard libraries. There is some way that the library can statically link a standard library. I have proven something like: g++ -c library -static-libstdc++ -o library.o ar rcs library.o library.a But if I do so there is no link to the standard libraries. Then I have proved this way: g++ library -static-stdlib -o library.o ar rcs library.o library.a But ask me to add a main function. Is there

Does Rust have Collection traits?

﹥>﹥吖頭↗ 提交于 2019-12-04 23:28:29
I'd like to write a library that's a thin wrapper around some of the functionality in BTreeMap . I'd prefer not to tightly couple it to that particular data structure though. Strictly speaking, I only need a subset of its functionality, something along the lines of the NavigableMap interface in Java. I was hoping to find an analogous trait I could use. I seem to recall that at some point there were traits like Map and MutableMap in the standard library, but they seem to be absent now. Is there a crate that defines these? Or will they eventually be re-added to std? No, right now there's only

Why is numCapabilities a pure function?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 15:42:37
问题 In the concurrency library GHC.Conc there is a function called numCapabilities. Its type is numCapabilities :: Int and it actually returns some number you passed by the command line flag (e.g. 5 if the options are +RTS -N 5 ). However, getArgs (type: IO [String] ) does essentially the same (it returns the unparsed non-runtime arguments) but isn't a pure function. If the only excuse is that numCapabilities is often needed in pure code, in what way aren't other command line options not needed

Is it possible to minimize the console in python with the standard librairy (without extra module)?

南笙酒味 提交于 2019-12-04 15:08:47
I wrote a program that uses the console. Most of the time, the user must see the console informations. For a specific function from command line, I would like to run the script without the console rises. I just don't want see the window but it can be in the task bar. I know I can use extra modules (gui, win32,..) to do that but I would like to use the standard python librairy. Is it possible to do that? The program should run on Windows. (python 2.7) I specify... I know I can use pythonw.exe too. The question then is how to launch the same script with python.exe sometimes and with pythonw.exe

Are there actual systems where difftime accounts for leap seconds?

天大地大妈咪最大 提交于 2019-12-04 11:43:37
The C standard (ISO/IEC 9899) states: 7.2x.2.2 The difftime function Synopsis #include <time.h> double difftime(time_t time1, time_t time0); Description The difftime function computes the difference between two calendar times: time1 - time0 . Returns The difftime function returns the difference expressed in seconds as a double . This leaves it ambiguous (I guess, intentionally) if the result accounts for leap seconds or not. The difference (26 seconds when comparing from 1970 to July 2015) matters in some applications. Most implementations of the C standard library do not account for leap

Why are many Python built-in/standard library functions actually classes

。_饼干妹妹 提交于 2019-12-04 05:40:21
Many Python builtin "functions" are actually classes, although they also have a straightforward function implementation. Even very simple ones, such as itertools.repeat . What is the motivation for this? It seems like over-engineering to me. Edit: I am not asking about the purpose of itertools.repeat or any other particular function. It was just an example of a very simple function with a very simple possible impementation: def repeat(x): while True: yield x But itertools.repeat is not actually a function, it's implemented as a class. My question is: Why? It seems like unnecessary overhead.

Requirements on standard library allocator pointer types

前提是你 提交于 2019-12-04 03:49:57
I am trying to write a quadtree sparse matrix class. In short, a quadtree_matrix<T> is either the zero matrix or a quadruple (ne, nw, se, sw) of quadtree_matrix<T> . I'd like eventually to test different allocation schemes since this will probably impact the performance of linear algebra operations. So I will also template quadtree_matrix on a standard allocator type, so that I can reuse existing allocators. I will have to allocate two different kind of data: either a T , or a node , which contains four pointers (to either T or node). For all the algorithms I will consider, I know for sure

Why standard containers use function templates instead of non-template Koenig operators

自作多情 提交于 2019-12-04 03:01:42
问题 This question is inspired by Issue with std::reference_wrapper. Let' say, for example, operator< for std::vector . It's defined as a function template as template< class T, class Alloc > bool operator<( const vector<T,Alloc>& lhs, const vector<T,Alloc>& rhs ); As a result, implicit conversion of function argument to the type of the corresponding function parameter is denied (basically because of its template nature). This greatly reduces the usefulness and convenience of std::reference

Compile a static library link with standard library (static)

半腔热情 提交于 2019-12-03 17:04:55
I'm trying to compile a static library (let's call it library.a). This library consumes resources of standard libraries. There is some way that the library can statically link a standard library. I have proven something like: g++ -c library -static-libstdc++ -o library.o ar rcs library.o library.a But if I do so there is no link to the standard libraries. Then I have proved this way: g++ library -static-stdlib -o library.o ar rcs library.o library.a But ask me to add a main function. Is there any possibility of creating a static library by statically linking also standard libraries (std ::