geometry – (Hilbert Plane) Given /_BAD, you can always construct /_B’A’D’ i.e., find a point D’ such that these two angles are congruent (by (C4)).

What you need to show is that:

(i) you can choose D’ so that it is in the interior of /_B’A’C’ (you can choose it so it
is in the same side of A’B’ as C’, but the main thing would be to show it is in the interior).

(i) Once you show this, then it is easier to show that the complementary angles are congruent (this is the subtraction part) — perhaps argue as in the line segments case.

So above is what I am told to prove. Now I do not want to move onto the second part(ii) until I can get the first part(i) completed. The included picture shows what I have done so far.

As for the axioms we are allowed to use, we are allowed to use I1-I3 and B1-B4 and C1-C6 of Hilbert’s axioms.

I am unsure if my proof is sound or does it have holes.

Euclidean geometry

Deadlock Detection | Should the node T4 point to T1 and T2?

This example regarding deadlock detection was shown during one of my lectures and I have a doubt about it. The image is shown below.

For deadlock detection mechanism, why does T4 point only to T2 and not T1? Chronologically, T1 requests for the exclusive lock before T4. So shouldn’t T4 point to T1 as well?

Dependency Graph

co.combinatorics – If Anna goes from point A to point B, each step can only move up or move right. How many method(s) is / are there?

If Anna goes from point A to point B, each step can only move up or move right. How many method(s) is / are there?(reference the grid below)

This is the grid

I’ve just recently learned permutations and combinations. Therefore, I understood how to answer problems regarding grids but only the type of questions with definite number of columns and rows. As shown in the picture above, the grids are different in size. I’m confused on how to solve this. I’d be happy if anyone could help.. Thank you.

calculus – Tangent Vector at a specific point

I was asked to parameterize the circle edge of d2 =${(x,y):x^2+y^2=9$ and $x+y>=0}$

enter image description here

Anyways I parametrized the circle edge within the bounds but now I have to find the tangent vector at (0, 3) and I am not exactly sure how to do that. Would I set (-3cos(t), 3sin(t)) equal to its bounds then solve first? Like -3cos(t)=pi/4, 3sin(t)=5pi/4 and then find r'(t)?

Do any programming languages use types as values? Would there be any point?

You say:

One thing I haven’t seen (…) is using a type as a value that can be passed around, allowing it to instantiate new objects, call static functions etc, while still providing all the benefits of strong type checking

Emphasis mine.

For example, I have 2 classes, J and K, both of which implement interface I and in some circumstances may be used in the same place.

And:

if the type itself can be passed I could have a function that takes a type implementing I and call whichever version of a static member function, based on the passed object

Emphasis mine.

Something that gets close is runtime interrogations. For example with simple C# pattern matching:

public static void Test<T>(T obj)
    where T: I
{
    if (obj is J objAsJ)
    {
        // use J, including static methods on J
    }

    if (obj is K objAsK)
    {
        // use K, including static methods on K
    }
}

This provides “all the benefits of strong type checking”. However, of course, has the drawback of forcing you to enumerate the possible types.

If the type is to be passed at runtime – for example, in a variable, as the question suggests – it means it is not known at compile time, so we lose that strong type checking. To pass a type at runtime but have some type information in compile time, we have generic type arguments and constraints, of course. Yet, that won’t give you access to static members.

I only see two paths to keep such strong type checking: We interrogate the object, as shown above. Or stronger generic constraints…


Another thing that gets close is static interface methods. If we can make a generic constraint to such interface, we could be able to use those static members.

Java has interfaces with static methods, but you can’t override those. So we need a language with has something like interfaces with static members that we can override. Rust is such language.

For example, I have 2 classes, J and K, both of which implement interface I and in some circumstances may be used in the same place.

I’ll have two types Dog and Sheep, and a trait Animal implemented for both.

if the type itself can be passed I could have a function that takes a type implementing I and call whichever version of a static member function, based on the passed object

Traits in Rust can have static functions, which we get to implement for each type.

I’ll show how to call both static and instance functions defined in a trait, getting a different result depending on the actual type. So it calls “whichever version of a static member function, based on the passed object”.

The reason I’m saying it gets very close is because I’ll never have a variable storing the type, which is what the title of the question suggests (“Do any programming languages use types as values?”).

To be fair, Rust has TypeID, which is just a number. It can be used to identify and compare types, but that’s about it.

Instead everything is type checked at compile time (which, according to comments, seems to be what you care about). Rust does not have runtime reflection.

Note: I’ll be using String (which is a heap allocated string), and i’ll be cloning it. Not efficient, but I don’t bother with lifetimes.


I’ll have two types Dog and Sheep:

struct Dog { name: String }
struct Sheep { wool: bool, name: String }

An Animal trait:

trait Animal {
    fn new(name: String) -> Self; // Self is the type that implements the trait
    
    fn name(&self) -> String;
    
    fn noise(&self) -> String;
    
    fn talk(&self) {
        println!("{} says {}", self.name(), self.noise()); // This is default impl.
    }
    
    fn specie() -> String;
}

And we implement the trait for both types. This is Animal for Dog:

impl Animal for Dog {
    fn new(name: String) -> Dog {
        Dog { name: name }
    }

    fn name(&self) -> String {
        self.name.clone()
    }

    fn noise(&self) -> String {
        "bark!".to_string()
    }
    
    fn specie() -> String
    {
        "Canine".to_string()
    }
}

This is Animal for Sheep.

impl Animal for Sheep {
    fn new(name: String) -> Sheep {
        Sheep { name: name, wool: true }
    }

    fn name(&self) -> String {
        self.name.clone()
    }

    fn noise(&self) -> String {
        if self.wool {
            "baaaaah!".to_string()
        } else {
            "baaaaah?".to_string()
        }
    }
    
    fn talk(&self) {
        println!("{} pauses briefly... {}", self.name, self.noise());
    }
    
    fn specie() -> String
    {
        "Ovine".to_string()
    }
}

Let us use them:

fn test<T: Animal>(animal: &T) {
    println!("{}", T::specie());
    animal.talk();
    let clone = T::new("Clone of ".to_owned() + &animal.name());
    clone.talk();
}

fn main() {
    let my_dog: Dog = Animal::new("Snuppy".to_string());
    let mut my_sheep: Sheep = Animal::new("Dolly".to_string());
    test(&my_dog);
    test(&my_sheep);
}

As you can see the test function is generic. It has a type argument T that must have an implementation of Animal. And it borrows an argument of that type.

We are able to call static functions defined in the trait:

println!("{}", T::specie());

Which outputs "Canine" for Dog and "Ovine" for Sheep.

We are able to call instance functions defined in the trait:

animal.talk();

We are able to create new instances of the same type we are given (this is just another static function):

let clone = T::new("Clone of ".to_owned() + &animal.name());

And use those those instances:

clone.talk();

Everything is type checked at compile time.

This is the output of the program:

Canine
Snuppy says bark!
Clone of Snuppy says bark!
Ovine
Dolly pauses briefly... baaaaah!
Clone of Dolly pauses briefly... baaaaah!

spells – Can a simulacrum heal non-hit point damage?

The spell Simulacrum, while open to interpretation on many fronts, is very clear on how to heal (repair) a damaged simulacrum, requiring a complex and costly process and a lab.

A complex process requiring at least 24 hours, 100 gp per hit point, and a fully equipped magical laboratory can repair damage to a simulacrum.

The spell mentions hit points directly, but a simulacrum can be damaged in many other ways such as ability damage, non-lethal Damage or even ability drain. It got me to wonder how to treat such types of damage.

I was thinking it would either :

  • Be immune to those types of damages (highly unlikely)
  • Heal those types of damages as a normal creature (by resting or using spells)
  • Heal those types of damages in a lab using the same process but without the cost (as the only cost mentioned is for hit points)
  • Be stuck with any such damages

I haven’t been able to find any definite answer on the internet.

How does a simulacrum treat those types of damage ?

sdl2 – Will using a fixed point library in C++ give me 100% deterministic replays?

I’m working on a scrolling arcade shooter in C++ with SDL2 and I’d like to have a replay function so players can save, share, and replay good runs. I understand that floating point math is not consistent from CPU to CPU, so saving inputs with frame counters won’t give you stable replays. I saw someone mention that fixed point math is a possible solution, so I’m currently working on a C++ engine using Libfixmath fix16_t datatypes in place of anything that would be a floating point.

Should this give me 100% deterministic replays across hardware if I save the random seed? From my understanding of how a fixed point math library works that should be the case, but I would like some confirmation before I bank my entire engine around this. Really my only concern is that I’m using literal floats to set the starting values for some things, like fix16_from_float(1.2) to set the player’s movement speed and I’m not entirely sure if CPU inconsistency could mess up that initial value and thus defeat the purpose. If so, could I solve the problem by using fix16_from_int() paired with some Libfixmath arithmetic to get the same non-integer values without ever using floats? I don’t quite have a complete grasp on how literals are stored into a compiled program.

I am also a tad worried about performance with potentially hundreds of onscreen bullets using high level fixed point math every frame, but I’ll have to see how much impact that has when I get to it.

floating point – What is the Difference Between Float and Double Data Types?

You can look up the concrete difference between float and double variables easily by searching for those terms; this group is not for answering simple definition queries, and anyway the details vary depending on your programming language and implementation.

But you can reason from fundamental principles about what the answer must be like. Increased memory size for a data type is a cost. A cost must be offset by some benefit, otherwise people wouldn’t bother having the costly type in the first place. The principal assets that computing systems deal in are time and space. Therefore, increased space requirements probably allow us to perform some computation in less time.

Why would this be? Doesn’t double simply support the same computation with higher precision? It is only the same computation as long as you don’t actually are about that higher precision. If you do care about a certain level of precision, then double allows you to do things in one step that you would otherwise have to emulate with multiple float operations.

And there you have your answer: double allows you to perform calculations in a particular range or at a particular precision that is greater than the range, or the precision, you could achieve with float values. This means that it very much depends on the details of your task description whether or not it is worthwhile to use the smaller or the larger numeric type. (And that is exactly the answer you’d get if you simply asked that question e.g. in a C programming forum.)

htaccess – Different robots.txt for two different domains point to same folder

Expanding on the earlier answer, you could use a single mod_rewrite rule to handle different robots.txt files for any number of subdomains.

For example:

RewriteEngine On

# Rewrite "robots.txt" to "robots-<subdomain>".txt
RewriteCond %{HTTP_HOST} ^(?!www)((a-z)+).example.com
RewriteRule ^robots.txt$ robots-%1.txt (L)

Any request for <subdomain>.example.com/robots.txt (except the www subdomain, as stated using the negative lookahead (?!www)) would be served by the corresponding /robots-<subdomain>.txt file. The www subdomain and the domain apex (ie. example.com) would be served by the default robots.txt file.

You could take this a step further and have the subdomain’s robots-<subdomain>.txt file served “if it exists” and fallback to the default robots.txt file if it doesn’t, by adding a filesystem check.

For example:

# Rewrite "robots.txt" to "robots-<subdomain>".txt if it exists
RewriteCond %{HTTP_HOST} ^(?!www)((a-z)+).example.com
RewriteCond %{DOCUMENT_ROOT}/robots-%1.txt -f
RewriteRule ^robots.txt$ robots-%1.txt (L)

Prevent direct access to robots-<subdomain>.txt

To prevent direct access to the /robots-<subdomain>.txt file you can add an external redirect before the above rewrite. For example:

# Redirect direct requests to "robots-<subdomain>.txt" to "robots.txt" on <subdomain>
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^robots-((a-z)+).txt$ https://$1.example.com/robots.txt (R=301,L)

The above would redirect a direct request for /robots-<subdomain>.txt (regardless of the hostname being requested) to https://<subdomain>.example.com/robots.txt. The check against the REDIRECT_STATUS env var ensures that only direct requests are redirected and not internally rewritten requests to /robots-<subdomain>.txt. Note that this uses the filename to determine the correct subdomain. eg. https://foo.example.com/robots-bar.txt would redirect to https://bar.example.com/robots.txt – changing the hostname, but ensures the same file is served.

To simply redirect to /robots.txt and keep the requested hostname. eg. https://foo.example.com/robots-bar.txt redirects to https://foo.example.com/robots.txt (which will result in robots-foo.txt being served by the above rewrite). Then the redirect can be simplified to:

# Redirect direct requests to "robots-<subdomain>.txt" to "robots.txt" on same host
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^robots-(a-z)+.txt$ /robots.txt (R=301,L)

Summary

RewriteEngine On

# Redirect direct requests to "robots-<subdomain>.txt" to "robots.txt" on <subdomain>
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^robots-((a-z)+).txt$ https://$1.example.com/robots.txt (R=301,L)

# Rewrite "robots.txt" to "robots-<subdomain>".txt
RewriteCond %{HTTP_HOST} ^(?!www)((a-z)+).example.com
RewriteRule ^robots.txt$ robots-%1.txt (L)

dnd 4e – Was Summon Succubus errataed at some point?

The Summon Succubus spell for Wizard, printed in Dragon 385, seems to have some issues that my group is trying to figure out. Specifically, we’ve found two versions of the Intrinsic Nature, and they are wildly different.

From the Dragon 385 PDF

Intrinsic Nature: If you haven’t given the succubus any commands by
the end of your turn, it shifts 1 square and attacks you or your
nearest ally within range.

and from the compendium (both offline and portable)

Intrinsic Nature: If you haven’t given the succubus any commands by
the end of your turn, it shifts 1 square and attacks the nearest enemy
within range that is not dominated. In addition, you are dazed until
the end of your next turn.

During the discussion, we’ve found some supporting secondary information for both, but the change is not present in either the compiled 4e errata or in the errata for Dragon 385.

In favor of the PDF is, well, the initial printing, as well as the individual article for Class Acts: Wizard. There’s also this power description in an old Wizard handbook on of our members dug up from 2010

Summon Succubus (D 385) Charm, Summoning: for lash-lovers this summon adds incredible control, in the form of constant field superiority. Each target can be dominated only once, but this is often enough. A great form of control, and the intrisic nature isn’t too shabby, even if it raises a question: if the succubus attacks an ally and dominates it, i am her controller, so the round isn’t completely wasted.

Which is odd since I would never describe that intrinsic as anything other than raw downside, but does acknowledge it dominating allies, which the compendium version cannot do.

Meanwhile, in favor of the compendium version is the character builder (though notably that is not a rules source) and the later Wizard handbook from 2012

Summon Succubus. (D385) Charm, Summoning. She dominates with her attacks. She can even do outside your turn if you’re willing to take being dazed (Hint, Superior Will). Her Symbiosis effect is nice, but nothing special, although it does help to counter the CA you grant from being dazed. A fantastic power.

This references both the general amazingness of a minor>no action dominate, as well as working to mitigate the daze drawback only present in the compendium version.

However, as mentioned, we can’t find any evidence of official errata or reprinting. Does anyone know where this change was made?