## I have index i need to get the element of this index from list – prolog

Can anyone tell me how to get the element from spifiec index ? Say for example I need to get the element in the index 5 in my list

## list manipulation – Using coding to calculate my average for functions defined on countable sets?

Suppose we have a function $$f:Atomathbb{R}$$ where $$Asubseteq(a,b)$$, $$a,binmathbb{R}$$ and $$Ssubseteq A$$.

Now suppose $$f$$ is

$$f(x)=begin{cases} x^2+1 & xin S_1\ x & xin S_2\ end{cases}$$

Where $$S_1$$ and $$S_2$$ are pairwise disjoint subsets of $$A=S_1cup S_2$$ where $$S_1=left{frac{1}{c}+frac{sqrt{2}}{2}:cinmathbb{Z}right}cap(0,1)$$, $$S_2=left{frac{1}{2^{(d_1)}}+frac{1}{2^{(d_2)}}:d_1,d_2inmathbb{Z}right}cap(0,1)$$ and $$(a,b)=(0,1)$$ where $$a=0$$ and $$b=1$$.

Suppose we divide $$(0,1)$$ into $$r$$ sub-intervals $$left{(x_{i-1},x_i)right}_{i=1}^{r}$$, where $$a=x_0le x_1 le …le x_i le …le x_{r-1}le x_r=b$$; and, if $$f$$ is defined in that sub-interval we take a point from that sub-interval; (however, if $$f$$ is not defined, we set $$f=0$$) and multiply it by measures $$mu(S_1cap(x_{i-1},x_i),A)$$, for $$f(S_1)$$, and $$mu(S_2cap(x_{i-1},x_i),A)$$, for $$f(S_2)$$,

We define $$mu(S_1,A)$$ and $$mu(S_2,A)$$ as the following:

In each sub-interval $$(x_{i-1},x_i)$$, we cover $$S_1cap (x_{i-1},x_i)$$ by $$m_1$$ sub-intervals, of each of the sub-intervals in $$left(I_{i}right)_{i=1}^{r}=left{(x_{i-1},x_i)right}_{i=1}^{r}$$. We define this as $$left(I_{i_1,k}right)_{k=1}^{m_1}$$, where $$1 le m_1 le maxleft{|S_1|,1right}$$. Then cover $$S_2cap(x_{i-1},x_i)$$ by $$m_2$$ sub-intervals of each of the sub-intervals in $$left(I_{i}right)_{i=1}^{r}=left{(x_{i-1},x_i)right}_{i=1}^{r}$$, which we define as $$left(I_{i_2,k}right)_{k=1}^{m_2}$$, where $$1 le m_2 le maxleft{|S_2|,Aright}$$. Last, cover $$A=S_1cup S_2$$ by $$n$$ sub-intervals of $$J=(a,b)$$, which we define as $$left(J_{k}right)_{k=1}^{n}$$ where $$1 le n le maxleft{|A|,1right}$$. All these sub-intervals have the same length which we define as $$cinmathbb{R}^{+}$$.

We wish to minimize (or find the infimum) of the total sum of the lengths of the $$m_1$$ sub-intervals covering $$S_1cap(x_{i-1},x_i)$$, where the infimum depends on $$c$$. This means we must set $$c$$ to specific values before taking the infimum. This would give us $$m_1$$ divided by $$n$$. The same is applied with $$m_2$$ sub-intervals covering $$S_2cap (x_{i-1},x_i)$$ and the $$n$$ sub-intervals covering $$Acap (x_{i-1},x_i)$$. This would give us $$m_2$$ divided by $$n$$.

Next we want want to find the infimum of $$m_1$$ divided by $$n$$ over $$c$$, (both $$m_1$$ and $$n$$ depends on $$c$$). We want the same with the infimum of $$m_2$$ divided by $$n$$ over $$c$$. This gives us $$mu(S_1cap(x_{i-1},x_i),A)$$ and $$mu(S_2cap(x_{i-1},x_i),A)$$.

To get our average one must take

$$sum_{i=1}^{r}(x_i^2+1)mu(S_1cap(x_{i-1},x_i),A)+sum_{i=1}^{r}(x_i)mu(S_2cap(x_{i-1},x_i),A)$$

Questions

1. How would we do this on Mathematica?
2. How would we generalize this to any piece-wise function defined on a countable set?

## My Attempt

``````Subscript(S, 1)(c_Integer, r_) :=
Select(Union@
Flatten(Table(
1/2^(Subscript(d, 1)) + 1/2^(Subscript(d, 2)), {Subscript(d, 1),
1, c}, {Subscript(d, 2), Subscript(d, 1), c})),
Between(#,
r) &)
``````

This lists all elements in $$S_1$$ as `c`$$toinfty$$ and groups them into $$r$$ sub-intervals of $$(0,1)$$

``````Subscript(S, 2)(c_Integer, q_) :=
Select(Union@
Flatten(Table(
1/Subscript(u, 1) + Sqrt(2)/2, {Subscript(u, 1), 1, c})),
Between(#,
q) &)
``````

This lists all elements of Set $$S_2$$ as and groups them into $$r$$ sub-intervals of $$(0,1)$$

``````Subscript(f, 1)(x_) :=
x^2
``````

This is the function $$f=f_1$$ on $$xin S_1$$

``````Subscript(f, 1, 1)(c_Integer, r_) :=
Subscript(f,
1) /@ (Subscript(S, 1)(c, #) & /@ Partition(Subdivide(r), 2, 1))
``````

Groups $$S_1$$ into $$r$$ sub-intervals

``````Subscript(f, 1, 1, 1)(c_Integer, r_) :=
Subscript(f, 1, 1)(c, r) /. {} -> {0}
``````

Converts null sets to zero

``````Subscript(f, 1, 1, 1)(30, 100);

Subscript(f, 2)(
x_) := x
``````

This is the function $$f=f_2$$ on $$xin S_2$$

``````Subscript(f, 2, 2)(c_Integer, r_) :=
Subscript(f,
2) /@ (Subscript(S, 2)(c, #) & /@
Partition(Subdivide(r), 2,
1)) (* Groups Subscript(S, 2) into r sub-intervals *)
Subscript(f, 2, 2, 2)(c_Integer, r_) :=
Subscript(f, 2, 2)(c, r) /. {} -> {0}
``````

Converts null sets to zero

``````In(205):=
Subscript(I, 1)(r_) :=
Block({m = 10^16},
With({k = Ceiling@Log2@N@m + 2},
Total(#) + 1 - Last(#) &@
Unitize@BinCounts(
Total(Tuples(2^Range(-k, -1), 2), {2}), {Min(#1) &, Max(#1) &,
1/m}))) /@ Partition(Subdivide(r), 2, 1)
``````

This is supposed to give $$m_1$$ from where the total sum of the length of all $$m_1$$ sub-intervals, of each of the $$r$$ sub-intervals, covering the intersection of $$S_1$$ and the $$r$$ sub-intervals are as small as possible.

``````In(206):= Subscript(I, 1)(10)

During evaluation of In(206):= BinCounts::bins: The bin specification {Min(#1)&,Max(#1)&,1/10000000000000000} is not a list of 2 or 3 real values.

Out(206)= If(29155653097335068495 === \$SessionID,
Out(206), Message(
MessageName(Syntax, "noinfoker")); Missing("NotAvailable"); Null)
``````

Unfortunately, there is something wrong with this function.

``````Subscript(I, 2)(r_) :=
Block({m = 10^16},
With({k = Ceiling@N@m + 2},
Total(#) + 1 - Last(#) &@
Unitize@BinCounts(
Total(Tuples(Range(-k, -1), 1), {2}), {Min(#1) &, Max(#1) &,
1/m}))) /@
Partition(Subdivide(r), 2,
1)
``````

This is supposed to give $$m_2$$ from where the total sum of the length of all $$m_2$$ sub-intervals, of each of the r sub-intervals, covering the intersection of $$S_2$$ and the $$r$$ sub-intervals are as small as possible

``````Subscript(I, 2)(10)
J(r_) := Sum(
Subscript(I, 1)(i) + Subscript(I, 2)(i), {i, 1,
r})
``````

This is supposed to give $$n$$ from where the total sum of the length of all $$n$$ sub-intervals, of each of the $$r$$ sub-intervals, covering the intersection of $$A$$ and the $$r$$ sub-intervals are as small as possible

``````Subscript(Avg, 1)(r_) :=
Sum(Subscript(f, 1, 1, 1)(30, i)((i, 1))*
Subscript(I, 1)(r)((i))/J(r), {i, 1,
r}) (* Subscript(I, 1)(r)((i))/A(r) is mu(Subscript(S, 1),A) as m
(Rule) Infinity, the whole sum is supposed to give the average over
Subscript(f, 1) *)
Subscript(Avg, 2)(r_) :=
Sum(Subscript(f, 2, 2, 2)(30, i)((i, 1))*
Subscript(I, 2)(r)((i))/J(r), {i, 1,
r}) (* Subscript(I, 1)(r)((i))/A(r) is mu(Subscript(S, 2),A) as m
(Rule)Infinity, the whole sum is supposed to give the average over
Subscript(f, 2) *)
Subscript(Avg, 1)(10000) +
Subscript(Avg, 1)(10000) (* This is the combined total sum *)

During evaluation of In(217):= General::nomem: The current computation was aborted because there was insufficient memory available to complete the computation.

During evaluation of In(217):= Throw::sysexc: Uncaught SystemException returned to top level. Can be caught with Catch((Ellipsis), _SystemException).

Out(218)= SystemException("MemoryAllocationFailure")

During evaluation of In(217):= BinCounts::bins: The bin specification {Min(#1)&,Max(#1)&,1/10000000000000000} is not a list of 2 or 3 real values.

During evaluation of In(217):= BinCounts::bins: The bin specification {Min(#1)&,Max(#1)&,1/10000000000000000} is not a list of 2 or 3 real values.

During evaluation of In(217):= General::nomem: The current computation was aborted because there was insufficient memory available to complete the computation.

During evaluation of In(217):= Throw::sysexc: Uncaught SystemException returned to top level. Can be caught with Catch((Ellipsis), _SystemException).

Out(222)= SystemException("MemoryAllocationFailure")
``````

Unfortunately, as you see here I am not getting any results.

How do we fix the errors in my code? Is my attempt correct?

## Sort Sharepoint Online List views alphabetically

I have multiple Sharepoint Online lists each with more than 100+ views created.
The problem is that these views are listed in the order of creation and not alphabetically .
To navigate to a particular view it is getting very cumbersome to scroll through the long list.

I would like to know if it is possible to sort them out easily without renaming.

An item belongs to a potentially infinite number of categories (usually most of them are spam).

After the item page loads, it shows one category link with the highest score (and thus probably non-spam) of all categories the item belongs to. There is `More...` button that loads with JavaScript 10 more categories (or less if the list of categories is exceeded). If `More...` is pressed twice, 20 categories would be loaded, etc.

1. How to make Google understand that `More...` leads to more links?

2. How to make Google understand that the lower the link is in the list, the more likely it’s spam?

## How to add a removed element to the associated sublist after manipulating a list

I have the attached point list and use the following script to cluster the points. The clustering should just be applied to the first three-member of each sublist so I removed the fourth element from each sublist. However, after clustering the fourth member should be added to the associated sublist. How I can do that.
https://pastebin.com/SKvFEEQD

``````A11 = Drop[dataDCMp, None, {4}];
nng = NearestNeighborGraph[A11, 4];
ccmp = ConnectedComponents[nng];
``````

## Submitting to SP List, Input string was not in correct format error JavaScript

I am getting the error, “Input list was not in correct format error”

My sharepoint list has single text fields so i cannot see the problem

function savingsdatick(varid) {
//Get Current Tabs before submission
var allTicksForSave = {};
\$(“.thischeck”).each(function () {
allTicksForSave(\$(this).attr(“id”)) = \$(this).is(“:Checked”)
});
console.log(“So…”)
console.log(allTicksForSave)

var Tickbox1 = “Tickbox1”;
var Tickbox2 = “Tickbox2”;
var Tickbox3 = “Tickbox3”;
var Tickbox4 = “Tickbox4”;
var Tickbox5 = “Tickbox5”;
var Tickbox6 = “Tickbox6”;
var Tickbox7 = “Tickbox7”;
var Tickbox8 = “Tickbox8”;
var Tickbox9 = “Tickbox9”;
var Tickbox10 = “Tickbox10”
var Tickbox11 = “Tickbox11”;
var Tickbox12 = “Tickbox12”;
var Tickbox13 = “Tickbox13”;
var Tickbox14 = “Tickbox14”;
var Tickbox15 = “Tickbox15”;
var Tickbox16 = “Tickbox16”;
var Tickbox17 = “Tickbox17”;
var Tickbox18 = “Tickbox18”;
var Tickbox19 = “Tickbox19”;
var Tickbox20 = “Tickbox20”;
var Tickbox21 = “Tickbox21”;
var Tickbox22 = “Tickbox22”;
var Tickbox23 = “Tickbox23”;
var Tickbox24 = “Tickbox24”;
var Tickbox25 = “Tickbox25”;
var Tickbox26 = “Tickbox26”;
var Tickbox27 = “Tickbox27”;
var Tickbox28 = “Tickbox28”;
var Tickbox29 = “Tickbox29”;
var Tickbox30 = “Tickbox30”;

``````  var varid = localStorage.getItem("projectnewTitle");
var currentStorm = document.getElementById("dale3").innerHTML;
var siteUrl = _spPageContextInfo.webServerRelativeUrl;
var clientContext =  SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('SecurityDesignAssuranceLeft');
this.oListItem = oList.getItemById(currentStorm)
if(allTicksForSave.SDALEFTBOX0) oListItem.set_item('Tickbox1', 'True');
if(allTicksForSave.SDALEFTBOX1) oListItem.set_item('Tickbox2', 'True');
// if(allTicksForSave.SDALEFTBOX2) oListItem.set_item(Tickbox3, "True")
// if(allTicksForSave.SDALEFTBOX3) oListItem.set_item(Tickbox4, "True")
// if(allTicksForSave.SDALEFTBOX4) oListItem.set_item(Tickbox5, "True")
// if(allTicksForSave.SDALEFTBOX5) oListItem.set_item(Tickbox6, "True")
// if(allTicksForSave.SDALEFTBOX6) oListItem.set_item(Tickbox7, "True")
// if(allTicksForSave.SDALEFTBOX7) oListItem.set_item(Tickbox8, "True")
// if(allTicksForSave.SDALEFTBOX8) oListItem.set_item(Tickbox9, "True")
// if(allTicksForSave.SDALEFTBOX9) oListItem.set_item(Tickbox10, "True")
// if(allTicksForSave.SDALEFTBOX10) oListItem.set_item(Tickbox11, "True")
oListItem.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded4), Function.createDelegate(this, this.onQueryFailed4));
function onQuerySucceeded4() {
``````

}

function onQueryFailed4(sender, args) {
}
}

## google sheets – Using REGEXMATCH with list input

I’m trying to see if a COL A contains anything from a specified list. (if it does, I put say a ‘1’ in COL B, or ‘0’ if not.

I’m currently doing it this slow, insane way. (putting this formula into col B – replace ‘I20’ with A20 for example).

Is there a better way?

``````=if(REGEXMATCH(I20,"SOUTHERN"),1,0) + if(REGEXMATCH(I20,"GLASS"),1,0) + if(REGEXMATCH(I20,"HOME"),1,0) + if(REGEXMATCH(I20,"JOHN"),1,0) + if(REGEXMATCH(I20,"ENTERPRISE"),1,0) + if(REGEXMATCH(I20,"BRITISH A"),1,0) + if(REGEXMATCH(I20,"WSELECTRICAL"),1,0) + if(REGEXMATCH(I20,"VIKING"),1,0) + if(REGEXMATCH(I20,"TASCHEN"),1,0) + if(REGEXMATCH(I20,"FRANCY"),1,0) + if(REGEXMATCH(I20,"MODELSHOP"),1,0) + if(REGEXMATCH(I20,"APPLE"),1,0) + if(REGEXMATCH(I20,"CURRYS"),1,0) + if(REGEXMATCH(I20,"WATFORD"),1,0) + if(REGEXMATCH(I20,"WICKES"),1,0) + if(REGEXMATCH(I20,"LEYLAND"),1,0) + if(REGEXMATCH(I20,"IKEA"),1,0)
`````` ## c# – Refresh the List box with new rooms from the server every 3 seconds

So i have a server which I send a Request to and it sends me back a list of rooms,Now i made a window for joining rooms and I’m trying to refresh it every 3 seconds but when i use the Timer thread to refresh the list it doesn’t work if I use the normal refresh method with the Timer it works just fine.
Here’s some code:

``````private void AutoRefresh()
{
System.Timers.Timer timer = new System.Timers.Timer(TimeSpan.FromMilliseconds(3000).TotalMilliseconds);
timer.AutoReset = true;
timer.Elapsed += new System.Timers.ElapsedEventHandler(this.Refresh);
timer.Start();
}

private void Refresh(object sender, System.Timers.ElapsedEventArgs elapsedEventArg)
{
GetRoomsResponse response;
response = SendAndRecv();
Button temp;
foreach (RoomData room in response.rooms)
{
temp = new Button { Content = room };
temp.Click += (sender, e) =>
{
JoinRoomClick(sender, e);
};
temp.Content = room.Name;
}
ListBoxRooms.ItemsSource = buttons;
}
``````

If I call refresh from the main it works perfectly if I call AutoRefresh it doesn’t I think it gets stuck on the for each loop no error’s just doesn’t do it’s job

## list manipulation – How to partition \$[0,1]\$ into \$m\$ equal sub-intervals and count the number of sub-intervals that intersect with my cantor set?

Suppose I define my cantor set as

`````` cantor = {a_,
b_} :> {{a, a + (b - a)*1/7}, {a + (b - a)*2/7,
a + (b - a)*3/7}, {a + (b - a)*4/7,
a + (b - a)*5/7}, {a + (b - a)*6/7, b}};
CantorRegion(c_Integer?NonNegative) :=
Module({ints},
ints = Flatten(
Nest(Flatten(Map(Function(s, s /. cantor), #), 1) &, {{0, 1}}, c)))
ListPlot(Table({CantorRegion(3)((c)), 0}, {c, 1,
Length(CantorRegion(3))}))
generateA(n_Integer) := CantorRegion(n)
`````` How do we divide $$(0,1)$$ into $$m$$ sub-intervals of equal length and count the number of sub-intervals that intersect with my cantor set?

My attempt:

``````In(11):= partition(a_List, s_) := Module({f, r}, f({}, x_) := {x};
f(l_List, x_) := If(x - l((1)) < s, Append(l, x), Sow(l); {x});
r = Reap(Fold(f, {}, a));
Append(r((2, 1)), r((1))))
partition({0, 1, 2, 7, 10, 11, 12}, 5)
(*{{0,1,2},{7,10,11},{12}}*)

Out(12)= {{0, 1, 2}, {7, 10, 11}, {12}}
``````

Unfortunately for my cantor set

``````partition(Flatten(generateA(5)), 5)
``````

I get the following:

``````Part::partw: Part 1 of {} does not exist.

Part::pkspec1: The expression {0,1/16807,2/16807,3/16807,4/16807,5/16807,6/16807,1/2401,2/2401,15/16807,16/16807,17/16807,18/16807,19/16807,20/16807,3/2401,4/2401,29/16807,30/16807,31/16807,32/16807,33/16807,34/16807,5/2401,6/2401,43/16807,44/16807,45/16807,46/16807,47/16807,48/16807,1/343,2/343,99/16807,100/16807,101/16807,102/16807,103/16807,104/16807,15/2401,16/2401,113/16807,114/16807,115/16807,116/16807,117/16807,118/16807,17/2401,18/2401,127/16807,<<1998>>} cannot be used as a part specification.
``````

How do we fix my code? Is there a better solution?

## Auto Upload verified list to hoster

hi..
my server just got hacked via bitcoin locker (ransomware) everything is lost (project.ser+verified list)
im wondering it would be cool if GSA has this feature ( upload current project or verified list txt ) to our hoster ,at least ftp them
just a suggestion