kandi X-RAY | pdf Summary
kandi X-RAY | pdf Summary
PDF reader
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of pdf
pdf Key Features
pdf Examples and Code Snippets
Community Discussions
Trending Discussions on pdf
QUESTION
In his paper Generics for the Masses Hinze reviews encoding of data type.
Starting from Nat
ANSWER
Answered 2022-Mar-14 at 18:05The difference is the category. Nat
is an initial algebra in the category of types. Rep
is an initial algebra in the category of indexed types. The category of indexed types has as objects type constructors of kind * -> *
, and as morphisms from f ~> g
, functions of type forall t. f t -> g t
.
Then Rep
is the initial algebra for the functor RepF
defined as follows:
QUESTION
I'm going through an example in A Taste of Linear Logic.
It first introduces the standard array with the usual operations defined (page 24):
Then suggests that a linear equivalent (using a linear logic for type signatures to restrict array copying) would have a slightly different type signature:
This is designed with the idea that array contains values that are cheap to copy but that the array itself is expensive to copy and thus should be passed along from use to use as a handle.
Question: The signatures for lookup and update correspond well to the standard signatures, but how do I interpret the signature for new?
In particular:
- The function new does not seem to return an array. How can I get an array to use if one is not provided?
- I think I do understand that
Arr –o Arr x X
is not derivable using linear logic and therefore a function to extract individual values without consuming the array is needed, but I don't understand why new doesn't provide that function directly
ANSWER
Answered 2022-Feb-28 at 10:13In practical terms, this is about garbage collection.
Linear logic avoids making copies as well as leaving unused values lying around. So when you create an array with new
, you also need to make sure it's eventually cleaned up again.
How can you make sure it is cleaned up? Well, in this example they do it by not giving back the array as the result, but instead “lending” it to the caller. The function Arr ⊸ Arr ⊗ X must give an array back in the end, in addition to the result you're actually interested in. It's assumed that this will be a modified form of the array you started out with. Only the X is passed back to the caller, the Arr is deallocated.
QUESTION
I was using pyspark on AWS EMR (4 r5.xlarge as 4 workers, each has one executor and 4 cores), and I got AttributeError: Can't get attribute 'new_block' on . Below is a snippet of the code that threw this error:
...
ANSWER
Answered 2021-Aug-26 at 14:53I had the same error using pandas 1.3.2 in the server while 1.2 in my client. Downgrading pandas to 1.2 solved the problem.
QUESTION
On page 12 of One Monad to Prove Them All, it is written that "a prominent example [of container] is the list data type. A list can be represented by the length of the list and a function mapping positions within the list".
At first I thought that the free monad on this container would be isomorphic the list monad.
But on page 12, it is written that "the list monad is not a free monad in the sense that the list monad is not isomorphic to an instance of the free monad".
So what is the free monad on the above container? What is it isomorphic to? Why isn't it isomorphic to the list monad? Can it be made isomorphic by quotient?
...ANSWER
Answered 2022-Feb-22 at 19:58I think one should be a bit careful.
I don't think it's the case that if M
is a free monad, then applying the free monad construction gets you back something isomorphic to M
. So your question of "what is the free monad on X
" is actually not related to "what functor is X
the free monad of?". To show that monad M
is not a free monad, the only thing we need to do is exhibit some equality that's true for M
but not implied by the monad laws -- since the meaning of the free monad construction is that it guarantees the monad laws and nothing else.
Here's one way to do that for lists:
QUESTION
When running this simple program, different behaviour is observed depending on the compiler.
It prints true
when compiled by GCC 11.2, and false
when compiled by MSVC 19.29.30137 with the (both are the latest release as of today).
ANSWER
Answered 2021-Dec-08 at 16:06GCC and Clang report that S
is trivially copyable in C++11 through C++23 standard modes. MSVC reports that S
is not trivially copyable in C++14 through C++20 standard modes.
N3337 (~ C++11) and N4140 (~ C++14) say:
A trivially copyable class is a class that:
- has no non-trivial copy constructors,
- has no non-trivial move constructors,
- has no non-trivial copy assignment operators,
- has no non-trivial move assignment operators, and
- has a trivial destructor.
By this definition, S
is trivially copyable.
N4659 (~ C++17) says:
A trivially copyable class is a class:
- where each copy constructor, move constructor, copy assignment operator, and move assignment operator is either deleted or trivial,
- that has at least one non-deleted copy constructor, move constructor, copy assignment operator, or move assignment operator, and
- that has a trivial, non-deleted destructor
By this definition, S
is not trivially copyable.
N4860 (~ C++20) says:
A trivially copyable class is a class:
- that has at least one eligible copy constructor, move constructor, copy assignment operator, or move assignment operator,
- where each eligible copy constructor, move constructor, copy assignment operator, and move assignment operator is trivial, and
- that has a trivial, non-deleted destructor.
By this definition, S
is not trivially copyable.
Thus, as published, S
was trivally copyable in C++11 and C++14, but not in C++17 and C++20.
The change was adopted from DR 1734 in February 2016. Implementors generally treat DRs as though they apply to all prior language standards by convention. Thus, by the published standard for C++11 and C++14, S
was trivially copyable, and by convention, newer compiler versions might choose to treat S
as not trivially copyable in C++11 and C++14 modes. Thus, all compilers could be said to be correct for C++11 and C++14.
For C++17 and beyond, S
is unambiguously not trivially copyable so GCC and Clang are incorrect. This is GCC bug #96288 and LLVM bug #39050
QUESTION
I'm trying to stop my elements from overlapping using interact.js, but I don't have any idea how to get the n elements to be able to do it. Does anyone have an idea? Or some other way I can validate it. Try the solution to this question, but I don't understand how to get the list of elements to go through it. enter link description here
...ANSWER
Answered 2021-Oct-03 at 18:14What you are looking for is collision detection. When you move or resize your box you can check if the new dimensions/position does collide with other boxes. If that is the case then you can ignore the movement/resize.
Because your code snippet contained a lot of invalid HTML I had to strip most of it to make it work. Please do spend some time making valid HTML when/if you ask your next question. Some errors that were present in your HTML code:
- All content was made in the
element
- Usage of HTML tags. Only certain tags can exist out of one tag like
is valid butis not and the proper way of writing some HTML tags like input is
(without closing tag)
- Closing tags
without any starting tags
- Closing parent tags before closing all the child tags
QUESTION
From the Idris 2 publication about linear types "Idris 2: Quantitative Type Theory in Practice":
For Idris 2, we make a concrete choice of semiring, where a multiplicity can be one of:
- 0: the variable is not used at run time
- 1: the variable is used exactly once at run time
- ω: no restrictions on the variable’s usage at run time
But for Haskell:
In the fashion of levity polymorphism, the proposal introduces a data type
...Multiplicity
which is treated specially by the type checker, to represent the multiplicities:
ANSWER
Answered 2021-Aug-19 at 00:37In Idris, the value of a function argument can appear in the return type. You might write a function with type
QUESTION
I have deployed a Django project using Apache2, everything is working fine except for weazyprint which creates PDF file for forms. The pdf was working fine in testing and local host.
Now everytime I access the pdf it is showing this error:
...ANSWER
Answered 2021-Aug-15 at 12:07Probably Weasyprint was not downloaded properly:
try:
QUESTION
I'm currently writing code using decimal.Decimal
in python (v3.8.5).
I was wondering if anyone knows how the Decimal object is actually encoded.
I can't understand why the memory size is the same even if I change getcontext().prec
, which is equal to change coefficients and exponent in decimal floating-points, as follows
ANSWER
Answered 2021-Aug-05 at 06:11For sys.getsizeof
:
Only the memory consumption directly attributed to the object is accounted for, not the memory consumption of objects it refers to.
Since Decimal
is a Python class with references to several other objects (EDIT: see below), you just get the total size of the references, which is constant — not including the referred values, which are not.
QUESTION
The OP of a recent question added a comment to it linking a paper entitled Common Compiler Optimisations are Invalid in the C11 Memory Model and what we can do about it, which apparently was presented at POPL 2015. Among other things, it purports to show several unexpected and counterintuitive conclusions derived from the specifications for what it calls the "C11 memory model", which I take to consist largely of the provisions of section 5.1.2.4 of the C11 language specification.
The paper is somewhat lengthy, but for the purposes of this question I focus on the discussion of scheme "SEQ" on the second page. This concerns a multithreaded program in which ...
a
is non-atomic (for example, anint
),x
andy
are atomic (for example,_Atomic int
), anda
,x
, andy
all initially have value0
,
... and the following occurs (transliterated from pseudocode):
Thread 1
...ANSWER
Answered 2021-Aug-01 at 23:55Apparently, no one is both interested enough and confident enough to write an answer, so I guess I'll go ahead.
isn't that argument fatally flawed?
To the extent that the proof quoted from the paper is intended to demonstrate that a conforming C implementation is not permitted to perform the source-to-source transformation described in the question, or an equivalent, yes, the proof is flawed. The refutation presented in the question is sound.
There was some discussion in comments about how the refutation could be viewed as boiling down to anything being permissible in the event of undefined behavior. That is a valid perspective, and in no way does it undercut the argument. However, I think it's unnecessarily minimalistic.
Again, the key problem with the paper's proof is here:
the load of
a
can only return 0 (the initial value ofa
) because the storea=1
does not happen before it (because it is in a different thread that has not been synchronised with) and non-atomic loads must return the latest write that happens before them.
The proof's error is that the language specification's requirement that a read of a
must return the result of a write to a
that "happened before" it is conditioned on the program being free of data races. This is an essential foundation for the whole model, not some kind of escape hatch. The program manifestly is not free of data races if in fact the read of a
is performed, so the requirement is moot in that case. The read of a
by thread 2 absolutely can observe the write by thread 1, and there is good reason to suppose that it might sometimes do so in practice.
To look at it another way, the proof chooses to focus on the write not happening before the read, but ignores the fact that the read also does not happen before the write.
Taking the relaxed atomic accesses into account does not change anything. It is plausible that in a real execution of the paper's three-threaded program, the implementation (for example) speculatively executes the relaxed load of x
in thread 2 on the assumption that it will return 1, then reads from a
the value written by thread 1, and as a result, executes the store to y
. Because the atomic accesses are performed with relaxed semantics, the execution of thread 3 can read the value of y
as 1 (or speculate that it will do so) and consequently perform the write to x
. All speculations involved can then be confirmed correct, with the final result that a = x = y = 1. It is intentional that this seemingly paradoxical result is allowed by the "relaxed" memory order.
isn't it indeed valid for a C11 implementation to treat the original three-threaded program as if it were the two-threaded program consisting of threads 2' and 3?
At minimum, the paper's argument does not show otherwise, even if we -- with no basis in the specification -- construe the scope of the UB arising from the data race to be limited to whether the value read from a
is its initial one or the one written by thread 1.
Implementations are given broad license to behave as they choose, so long as they produce observable behavior that is consistent with the behavior required of the abstract machine. The creation and execution of multiple threads of execution is not itself part of the observable behavior of a program, as that is defined by the specification. Therefore, yes, a program that performed the proposed transformation and then behaved accordingly, or one that otherwise behaved as if there were a happens before edge between the write to a
and the read from a
, would not be acting inconsistently with the specification.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pdf
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page