Why are nested anonymous pure functions shielded from evaluation?

I tried the following code (ignoring the warning messages):

{#, # &, Function({x}, #), Function({#}, x), Function({#}, #)} &@7
(*result: {7, #1 &, Function({x}, 7), Function({7}, x), Function({7}, 7)}*)

I wonder why #& was not changed into 7&.
I saw a "possible issue" similar to this mentioned in ref/Slot, but I couldn’t find further documentation about it. Is it a bug or it is specially designed this way?

functions – How to get the progressive application of list of rules?

all.
I need some suggestion on this problem.

I have a very long list of rules, using this list of rules I want to see how some elements evolve as I successively apply the next rules on the previous rule.
Here is the simpler version of my problem. I have no clue how to proceed, kindly suggest an approach to this problem.

ClearAll[Evaluate[StringJoin[Context[], "*"]]]
Needs["Utilities`CleanSlate`"]; 
CleanSlate[]; 
ClearInOut[];
 
myRules = {a5 -> a4/a3, a4 -> a3 + a2, 
    a3 -> a2^2 + a1, a2 -> a1 - 1, a1 -> b};  
 

I wanted to get this list

{  
 myRules[[1]] //. myRules[[2]],  

  myRules[[1]] //. myRules[[2]] //. 
   myRules[[3]],  

  myRules[[1]] //. myRules[[2]] //. 
    myRules[[3]] //. myRules[[4]],  

  myRules[[1]] //. myRules[[2]] //. 
     myRules[[3]] //. myRules[[4]] //. 
   myRules[[5]]  
 }

Why are these expressions with shifted delta functions not equal?

I have the following equation

Exp(a-t)*DiracDelta(t-a) == DiracDelta(t-a)

which cannot be evaluated. However, if I plug in 0 for a:

In(1) = Exp(t)*DiracDelta(t) == DiracDelta(t)
Out(1) = True

This does not seem to work with values other than 0.

Of course, the equality with delta functions may be mathematically tricky, but in this case Exp(a-t) == 1 for a == t, thus the first expression should yield True (in my opinion…). How can I get to this value?

This python code converts integers to strings and strings to ints without the inbuilt functions “int()” and “str()”

It is my solution from a challange from edabit.com named “Drunken Python”. Thats the task:
You need to create two functions to substitute str() and int(). A function called int_to_str() that converts integers into strings and a function called str_to_int() that converts strings into integers.

I hope you can tell me things I could do better and if the algorithms I used (e.g. to calculate the length of an int) are optimal.

# A function called int_to_str() that converts integers into strings and a function called str_to_int() that
# converts strings into integers without using the in built functions "int()" and str().


def str_to_int(num_str):
    dec_places = {11: 10000000000, 10: 1000000000, 9: 100000000, 8: 10000000, 7: 1000000, 6: 100000, 5: 10000, 4: 1000,
                  3: 100, 2: 10, 1: 1}
    char_digit = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
    num = 0
    length = len(num_str)
    for i in range(length):
        x = char_digit(num_str(0 - (i + 1))) * dec_places(i + 1)
        num = num + x
    return num


def calculate_length(num):
    div = 10
    i = 1
    while num / div >= 1:
        div = div * 10
        i = i + 1
    return i


def int_to_str(num_int):
    word = ""
    div = 10
    char_digit = {0: '0', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9'}
    length = calculate_length(num_int)
    for i in range(length):
        x = (num_int % div) // (div // 10)
        word = char_digit(x) + word
        num_int = num_int - x
        div = div * 10
    return word
```

functions – Comparing elements in a list and ignoring white space

I have two lists with element entries. I want Mathematica to identify an element in an opposing list such as Ag107 to be the same as Ag 107 ignoring any space. Each different element occurs only a single time in an individual list. I am comparing lists to see what elements they share. They are pulled in from csv so I am not sure if they are classified as strings or whether I need to convert them to strings in Mathematica. Unfortunately the two lists have inconsistent naming conventions within the list themselves, so the individual lists use a mixture of spaces and no spaces. I am using functions such as Complement, Position, ContainsExactly, MemberQ.

formal languages – First-order mutual-recursive functions Turing-complete or incomplete?

Suppose we have an ML-like programming language with only first-order terms (i.e. no higher-order functions/lambdas; variables cannot be functions). However, the language allows recursion in all forms.

Is it true that this language is Turing-incomplete, but becomes complete if we add basic heap semantics (i.e. pointers and manipulation of RAM-like memory)?

measure theory – Absolutely continuous functions that fix zero and satisfies $f'(x)=2f(x)$

A past question from a qualifying exam at my university reads:
Let $f$ be a continuous real-valued function on the real line that is differentiable almost everywhere with respect to the Lebesgue measure and satisfies $f(0)=0$ and
$$ f'(x)=2f(x)$$
almost everywhere. Prove that there exists infinitely many such functions, but that only one of them is absolutely continuous.

I have tried modifying the function $e^{2x}$, but I cannot satisfy all the conditions given.

Once one shows that there are infinitely many such functions, then if we pick 2 such functions $f_1$ and $f_2$ and fix $a>0$, we can apply the fundamental theorem of Calculus for Lebesgue Integrals on $(0,a)$ and see that if both are absolutely continuous, then
$$ f_1(x)=int_0^x 2f(t)dt=f_2(x) $$
So this would imply that the are the same function on $(0,infty)$. I’m not sure how to proceed with the whole real line.

probability theory – Characteristic functions and convergence of complex sequence

I’m trying to solve the following question, but I have no idea why the hint was given as it was:

enter image description here


My attempt: I’m not really able to make use of the hint so far, so I’m a bit lost:

The assumptions give that $e^{i t x_n} rightarrow c(t) + i s(t) equiv z(t)$ for some real functions $s(t), c(t)$ with $cos(x_n t) rightarrow c(t)$, $sin(x_n t) rightarrow s(t)$.

$z(t)$ cannot be zero for any $t$ since $||e^{itx_n}| – |z(t)|| leq |e^{itx_n} – z(t)|$ and $|e^{itx_n}| = 1$ so that $|z(t)| = 1$

$$E(e^{i t x_n U}) = f(x_n) equiv begin{cases} frac{e^{itx_n} – 1}{itx_n} & x_n ne 0 \
1 & x_n = 0 end{cases}$$

Dominated convergence gives us that $$E(c(tU) + i s(tU)) = lim_{n rightarrow infty} f(x_n)$$

Unfortunately I am not sure where to go from here.

partitioning – PostgreSQL functions for creating and dropping declarative partioning

I created function for creating declararative partitions.

CREATE OR REPLACE FUNCTION createpartition(table_name varchar(25), forecast_id integer) RETURNS varchar(30) AS $$
DECLARE
    partition_name varchar(30);
    sql_query text;
BEGIN
    partition_name = table_name || '_' ||  forecast_id::varchar(10);
    sql_query = format('CREATE TABLE %I PARTITION OF %I FOR VALUES IN (%L)', partition_name, table_name, forecast_id);   
    EXECUTE sql_query;
    RETURN partition_name;
EXCEPTION
    WHEN duplicate_table THEN 
        RAISE NOTICE 'caught duplicate_table'; 
        RETURN 'duplicate_table'; 
    WHEN OTHERS THEN 
        RAISE NOTICE 'caught others'; 
        RETURN 'others';   
END;
$$ LANGUAGE plpgsql;

I want to create similar function for dropping partitions.

But I see in one of answers on Postgresql function to create table

yes, this is possible. however, you have to be a little careful. DDLs
in a stored procedure USUALLY work. in some nasty corner cases you
might end up with “cache lookup” errors. The reason is that a
procedure is basically a part of a statement and modifying those
system objects on the fly can in rare corner cases cause mistakes (has
to be). This cannot happen with CREATE TABLE, however. So, you should
be safe.

Can a “cache lookup” error happen with CREATE TABLE … PARTITION OF .. or DROP TABLE, if they using in procedure?

linear algebra – Do products of distance functions separate points?

Let $(X,d)$ be a metric space without isolated points and of diameter $1$. Let ${y_n}_n$ be a dense subset of $X$.

Define $g_0equiv 1$, and for $n>0$ let $g_n=d(cdot,y_1)…d(cdot,y_n)$.

I wonder if ${g_0,g_1,…}$ separate points of $X$ in the following strong sense:

If $x_1,…,x_nin X$, $a_1,…,a_ninmathbb{R}$ are such that $a_1g_m(x_1)+…+a_ng_m(x_n)=0$, for every $m=0,1,…$, then $a_1=…=a_n=0$.

I can prove this when $n=1,2,3$, but not more, and even for $n=3$ the proof is somewhat lengthy, since one has to consider cases when some of $x_i$ are present among $y_j$.