## Was this an idiomatic and prudent way to extend R’s matrix multiplication syntax? Should I have used R’s object system?

After reading one too many Lisp books, I decided to try extending R’s syntax. My goal was to implement repeated matrix multiplication in a way such that I could write `matrix%^%n` to produce the result from multiplying `matrix` by itself `n` times (where `n` is a natural number). I produced the following working code that gives the expected outputs, but found it unsatisfactory.

```````%^%`<-function(squareMat,exponent)
{
stopifnot(is.matrix(squareMat),is.numeric(exponent),exponent%%1==0)
out<-diag(nrow = nrow(squareMat))
for(i in seq_len(exponent)){out<-squareMat%*%out}
out
}
testMatrix<-matrix(c(0,10,20,30),2,2)
lapply(0:3,function(k) testMatrix%^%k)#tests
``````

For the purposes of this question, I’m happy to ignore the contents of my `for` loop. I know that it’s not optimised. What I’m more interesting in investigating is if this was a prudent way to extend R’s syntax. I have listed my objection to my code below. If they are valid, how can they be addressed?

1. The method for checking if `exponent` is an integer is pathetic. I don’t think that doing better is possible, but I would dearly love to be proven wrong.
2. My strongest objection is that I believe that this problem calls for an S3 or S4 solution, but I do not believe that one is possible. `isS4(testMatrix)` tells me that matrices are not S4 objects, ruling that out. S3 might be possible, but I’m unsure if this will make problem #1 even worse (because S3 is not very strict on types) or requiring risky hacking of the `matrix` type.
3. Because of problem #1, `stopifnot` does not throw useful error messages.
4. The job of throwing errors regarding the multiplication is delegated to `%*%`. I’m OK with that, but I don’t know if I should be.
5. Again, ignoring the content of the `for` loop, was `for` actually the right thing to use? Is there something like an `apply` family function for “the index of my loop doesn’t actually matter, I just want to run this code `seq_len(exponent)` times”?

## syntax – Auto-Populate Date in Column When Seperate Column Gets Filled

I’ve checked around a few other questions asked around this, but none have really applied to what I am looking for.

Using Sharepoint 2019 Online, we have a sheet that contains 12 different columns. What we want to do, is when someone puts in a number for “PO #” column, that “Date PO Issued” field automatically fill with todays date. This way we can avoid empty fields when accounting is entering info.

I’ve been toying with a few different calculated values, but none seem to be working. Is calculated value the place for this to be done? Can it even be done?

This is what I came up with for adding todays date

`=DATE(YEAR(Today),MONTH(Today),DAY(Today))`

Then tried to add on that to depend on column 2, which is titled PO #. None of these seemed to be proper syntax

`=ISNUMBER((Col2))DATE(YEAR(Today),MONTH(Today),DAY(Today))`

`(IF((Column 2)="PO #",TEXT(NOW(),"mm/dd/yyyy"))`

I appreciate it. Fairly new to administrating sharepoint, so still learning everything.

## php – Syntax error or access violation: 1066 Not unique table/alias com relacionamento polimórficos no Laravel

Estou quebrando a cabeça a semanas e não consigo resolver este problema.

Estou usando este pacote https://github.com/rappasoft/laravel-livewire-tables para utilizar Datables no Laravel com Livewire.

Tenho os models com os seguintes relacionamentos:

User.php

``````public function getAdminAttribute()
{
}

{
}

public function getCoachAttribute() //permite pegar o \$user->coach direto (encapsulamento)
{
return \$this->coaches->first();
}

public function coaches()
{
return \$this->morphedByMany(Coach::class, 'userable');
}

public function getAthleteAttribute()
{
return \$this->athletes->first();
}

public function athletes()
{
return \$this->morphedByMany(Athlete::class, 'userable');
}
``````

Athlete.php

``````public function coach()
{
return \$this->belongsTo(Coach::class);
}

public function getUserAttribute()
{
return \$this->users->first();
}

public function users()
{
return \$this->morphToMany(User::class, 'userable');
}
``````

Coach.php

``````public function athletes()
{
return \$this->hasMany(Athlete::class);
}

public function getUserAttribute()
{
return \$this->users->first();
}

public function users()
{
return \$this->morphToMany(User::class, 'userable');
}
``````

E a tabela pivo:

``````public function up()
{
Schema::create('userables', function (Blueprint \$table) {
\$table->integer('user_id');
\$table->morphs('userable'); //nullableMorphs
});
}
``````

No tabela component do Livewire do pacote:

``````public function query() : Builder
{
return Athlete::with(('coach.users:id,name', 'users:id,name'))->where('company_id', \$this->companyId);
}

public function columns() : array
{
return (
Column::make('Avatar', 'avatar')
->format(function(Athlete \$model) {
return \$this->html('<img class="rounded-circle m-0 avatar-sm-table" src="'. asset("images/users/{\$model->user->id}/{\$model->user->avatar}") .'" alt="avatar">');
})
->excludeFromExport(),
Column::make('Nome', 'users.name')
->searchable()
->sortable(/* aqui é o problema */)
->format(function(Athlete \$model) {
return \$this->html(\$model->user->name);
}),
->searchable()
//->sortable()
->format(function(Athlete \$model) {
return \$this->html(\$model->coach->user->name);
}),
Column::make('Ações', 'actions')
->format(function(Athlete \$model) {
return \$this->html(
'<a href="'. route('athletes.profile', ('uuid' => \$model->uuid)) .'" class="btn btn-outline-info btn-icon m-0 m-0" data-toggle="tooltip" data-trigger="hover" data-original-title="Ver atleta" title="Ver atleta" target="_blank">
<i class="nav-icon fas fa-eye font-weight-bold"></i>
</a>
<a href="#" wire:click.prevent="showConfirmation('. \$model->uuid .')" class="btn btn-outline-danger btn-icon m-0 m-0 alert-confirm" data-toggle="tooltip" data-trigger="hover" data-original-title="Desvincular atleta da empresa" title="Desvincular atleta da empresa">
<i class="nav-icon fas fa-user-times font-weight-bold"></i>
</a>'
);
})
->excludeFromExport(),
);
}
``````

``````IlluminateDatabaseQueryException
SQLSTATE(42000): Syntax error or access violation: 1066 Not unique table/alias: 'users' (SQL: select count(*) as aggregate from `athletes` left join `userables` on `userables`.`userable_id` = `athletes`.`id` left join `users` on `userables`.`user_id` = `users`.`id` left join `users` on `userables`.`user_id` = `users`.`id` where `company_id` = 1)
``````

Deveria ter como criar um Alias?, mas acontece que o pacote faz isso automaticamente (estes joins) e não entendi como contornar.
Já tentei inúmeras coisas e não da certo,

Inclusive no trecho comentado ali `aqui é o problema`, no git do pacote, eles dizem para quando precisar contornar algo diferente no sortable(), para fazer ali dentro usando o Builder. No caso eu tentei fazer isso:

``````Column::make('Nome', 'users.name')
->searchable()
->sortable(function (\$builder, \$direction) {
return \$builder->join('userables', 'athletes.id', '=', 'userables.userable_id')
->join('users', 'users.id', '=', 'userables.user_id')
->where('userables.userable_type', '=', Athlete::class)
->orderBy('users.name', \$direction);
} )
->format(function(Athlete \$model) {
return \$this->html(\$model->user->name);
})
``````

Assim não acontece nenhum erro, mas não ordena corretamente pelos nomes.

Alguém consegue me ajudar nisso?

## syntax – What is the right way to solve this equation in R, it does not work for me with either solve or reduce? Are there any other commands?

in this equation i must find or clear rb , but MMA is reluctant to calculate it .
Am I doing something wrong? Logarithms should always be positive

``````Reduce(qb == (ta -
tb)/(ri ((1/(ri*hi)) + log((re/ri)/k) +
log((rb/re)/k0) + (1/(re*he)))) && ri != 0 && hi != 0 &&
re != 0 && he != 0 && k != 0 && k0 != 0 && rb != 0 &&
rb/(k0 re) > 0 && re/(k ri) > 0, rb) // FullSimplify
``````

note that ri not is r * i

## python – syntax error? Im literally copying it at this point

#I am having a syntax error in the colon after the ‘if another roll line’
#If I copy-paste the code it works but when I type it out it won’t.

import random

print(“Welcome to dice roller”)

min_value = 1
max_value = 20

roll = True

while roll:
print(random.randint(min_value, max_value))

``````another_roll = (input("Would you like to roll again? ")

if another_roll == 'yes' or another_roll == 'y':

roll = True

else:
roll = false
``````

## syntax – Repeated For Loop on Different Inputs Showing Same Results

I ran the same `For` Loop on different input data and faced the problem that the result lists were all identical, despite the input data being different, as shown in the image below (`network1` and `network2` are different datasets). I presume I am making a technical mistake, if anyone could help me out I’d greatly appreciate it.

Evl( ) is the `For` Loop command

First set:

``````Evl(Network1);
Evl1 = Evl;
Histogram({Evl1})
``````

Second set:

``````Evl(Network2);
Evl2 = Evl;
Histogram({Evl2})
``````

Basically organised in this order and tried plotting histograms of Evl1 and Evl2 which gave identical graphs that they shouldn’t.

## My question to the community is this:

What makes C#’s LINQ Unique from other query language in other languages and frameworks, or does it not have anything to make it unique at this point?

Specifically with regard to Django or Laravel, but that doesn’t matter all that much. I’m not looking for an opinion of why someone might like it more but rather if there is any concrete difference between them that a general developer would be inclined to choose one over the other because of that difference.

## Thoughts

Before I posted this I found this SE post (Python Unique Characteristics), that talks about it may be rather hard to find something that is actually unique. Which is a valid point, however the reason I ask is because I know a lot of .NET developers that use LINQ as a main selling point of .NET (myself included). However, when thinking about it more in depth I don’t know if it is a valid argument anymore which is more what I’m trying to accomplish with this question.

## What follows is context

My coworker and I were debating on the reason why LINQ (in the context of C#) could be an argument to use C# over another language. Especially when it can be compared to other DSLs like it (At least I believe it’s a kind of DSL, could be wrong though). We could not actually think of any concrete reason why LINQ would have any distinct advantage, feature or unique oddity over any other query syntax in a modern language or framework. The closest I could come up with was that you could write an underlying driver for LINQ to allow it to theoretically work with just about any data system out there, but the argument could me made that other languages support stuff like that as well.

Part of this question is due to an on going internal discussion between our devs about the merits of C# vs Django, but that is an entirely other area not for the scope of this question.

## General Information

The following are some locations where I have been looking to try and find information at least from more official sources.

## differential equations – Solving composite function ODEs but facing syntax difficulties

Today is my first day using Mathematica to solve PDEs and ODEs. I have coded this block:

``````vAcross(theta_) = vIn Sqrt(Sin(b) Cos(theta) ((Sin(a))^2 Cos(a) Sin(b)
- 2 Sin(a) Cos(a) Cos(b) + Sin(b) Cos(theta))),

re(vAcross(theta_)) = (rho vAcross(theta) dWire)/mu,

nu(re(vAcross(theta_))) = (0.376 re^(1/2) + 0.057 re^(2/3)) pr^(1/3)
+ 0.92 (Log(7.4055/re) + 4.18 re)^(-1/3)
``````

in order to obtain nu(theta), but I constantly get syntax errors such as

Syntax::tsntxi: “vAcross(theta_)=vIn Sqrt(Sin(b)Costheta),<<1>>,nu(re(vAcross(theta_)))=(0.376re^(1/2)+0.057re^(2/3))pr^(1/3)+0.92(Log(7.4055/re)+4.18re)^(-1/3)” is incomplete; more input is needed.

## migrating oracle to postgresql getting syntax error in at or near "RETURNING" keyword. kindly make this error free

select XMLQUERY(REPLACE(TRANSLATE(UPPER(coalesce(numstaff, 0)), ‘1ABCDEFGHIJKLMNOPQRSTUVWXYZ’, ‘1’), ‘/’, ‘ div ‘)
RETURNING CONTENT).getNumberVal() numstafftotal
, busi_hour_wd
FROM ris_shop_profile
where isshopactivated = ‘Y’;

## mysql – Database error: You have an error in your SQL syntax term_taxonomy

It’s been a while since this syntax error has been happening, I tried to look it up, have read articles and forum’s posts on this issue, but I still couldn’t fix it. It says I have an error on my database, but I’m afraid it might be my server. This mysql error is happening when I edit articles. I wished I could explain this better, but I have no idea of what’s going, this is what I get when I check the error log (a part or two might be odd because I translated to English):

WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near `') AND (2u98_posts.post_author <> 77777 OR ( (2u98_term_taxonomy.taxonomy = "...' at line 3 for query SELECT SQL_CALC_FOUND_ROWS 2u98_posts.ID FROM 2u98_posts LEFT JOIN 2u98_term_relationships ON (2u98_posts.ID = 2u98_term_relationships.object_id) LEFT JOIN 2u98_term_taxonomy ON ( 2u98_term_relationships.term_taxonomy_id = 2u98_term_taxonomy.term_taxonomy_id ) WHERE 1=1 AND ( 2u98_term_relationships.term_taxonomy_id IN (152) ) AND ( (2u98_term_taxonomy.taxonomy = "author" AND 2u98_term_taxonomy.term_id = '345')) AND 2u98_posts.post_type = 'post' AND (2u98_posts.post_status = 'publish' OR 2u98_posts.post_status = 'queued' OR 2u98_posts.post_status = 'processing' OR 2u98_posts.post_status = 'hold') AND (2u98_posts.post_author <> 77777 OR ( (2u98_term_taxonomy.taxonomy = "author" AND 2u98_term_taxonomy.term_id = '345')) AND EXISTS (SELECT 1 FROM 2u98_postmeta WHERE 2u98_postmeta.post_id = 2u98_posts.id AND 2u98_postmeta.meta_key = "_wp_attachment_metadata"))) AND (2u98_posts.post_author <> 77777 OR ( (2u98_term_taxonomy.taxonomy = "author" AND 2u98_term_taxonomy.term_id = '345')) AND EXISTS (SELECT 1 FROM 2u98_postmeta WHERE 2u98_postmeta.post_id = 2u98_posts.id AND 2u98_postmeta.meta_key = "_wp_attachment_metadata"))) GROUP BY 2u98_posts.ID ORDER BY 2u98_posts.post_date DESC LIMIT 0, 5 made by require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts`