multithreading – Parallel map in Rust

A parallel map written in Rust. I am new to Rust and wondering if there is things that could be done better or more efficiently.

use crossbeam_channel::unbounded;
use std::{thread, time};

fn parallel_map<T, U, F>(mut input_vec: Vec<T>, num_threads: usize, f: F) -> Vec<U>
    F: FnOnce(T) -> U + Send + Copy + 'static,
    T: Send + 'static,
    U: Send + 'static + Default,
    let mut output_vec: Vec<U> = Vec::with_capacity(input_vec.len());
    let mut threads = Vec::new();

    let (in_s, in_r) = unbounded::<(T, usize)>();
    let (out_s, out_r) = unbounded::<(U, usize)>();

    for _ in 0..num_threads {
        let in_r = in_r.clone();
        let out_s = out_s.clone();
        threads.push(thread::spawn(move || {
            while let Ok((value, index)) = in_r.recv() {
                let res = f(value);
                out_s.send((res, index)).expect("Failed to send");

    while let Some(val) = input_vec.pop() {
        in_s.send((val, input_vec.len())).expect("Failed to send");


    let mut collect_results: Vec<(U, usize)> = Vec::with_capacity(output_vec.capacity());
    while let Ok(res) = out_r.recv() {

    collect_results.sort_by(|(_, a_index), (_, b_index)| a_index.partial_cmp(b_index).unwrap());

    output_vec.extend(collect_results.into_iter().map(|(val, _)| val));

    for thread in threads {
        thread.join().expect("Failed to join thread");


fn main() {
    let v = vec!(6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 12, 18, 11, 5, 20);
    let squares = parallel_map(v, 10, |num| {
        println!("{} squared is {}", num, num * num);
        num * num
    println!("squares: {:?}", squares);

Define a unique linear map

Let $$L_1=left(
a & b \
c & d \

$L_1(1,2)=(0,-1)$ means that $(a+2 b,c+2 d)=(0,-1)$

$L_1(-1,1)=(2,1)to (b-a,d-c)=(2,1)$

So we have the linear system

which gives
$$a= -frac{4}{3},b= frac{2}{3},c= -1,d= 0$$
and finally
-frac{4}{3} & frac{2}{3} \
-1 & 0 \

Evaluating $k$ order derivative of a composition map at some point $t$. Rudin 9.30.

The problem statment. Let $fin C^m(E)$, where $E$ is an open subset of $Bbb{R^n}$. Fix $ain E$, and suppose $xin Bbb{R^n}$ is so close to $0$ that the points $p(t) a+ tx$ lie in $E$ whenever $1geq tgeq0$. Define $h(t)=f(p(t))$ for all $tin Bbb{R}$ for which $p(t)in E$. Problem : For $mgeq kgeq1$, show that $h^{(k)}(t)=sum(D_{i_1 …i_k}f)(p(t))x_{i_1}…x_{i_k}$. The sum extends over all ordered k-tuples $(i_1…i_k)$ in which each $i_j$ is one of the integers $1,…,n$.

Using the chain rule repeatedly is recommended, so I computed $$h^{(1)}(t)=h'(t)=f'(p(t))cdotp p'(t)=sum_i^n(D_if)(p(t))cdot x_i$$

But then $h^{(2)}=f”(p(t))cdot p”(t)=0.$ It doesn’t seem like this kind of process will lead towards the answer. Suggestions?

How to find all locations from a source point at Google Map?

Taking a scenario. I searched a location at

Taking the location as a centre, how to find all locations around the location within a radius of certain meter or kilometre?

With Regards

trains – List or map of publicly available wifi hotspots in Europe

Are there lists or map websites that show all widely known, publicly-provided wi-fi hotspots in continental Europe with free log in? By public, I mean non-civilian/private, such as state-endorsed (train stations) or heavily commercial (McDonalds hotspots). Country or city-specific maps would be a start too

etcd – Kubernetes API: Compare and update config map key

Etcd has a concept of Atomic Compare-and-Update by comparing the key’s value before executing an update. I’d like to use this feature for updating a ConfigMap in my Kubernetes cluster. I’d like to update the config map only if the existing config map data or a specific data key matches a certain value.

Example ConfigMap:

curl -X POST -H 'Content-Type: application/json' 
    -d '{"apiVersion": "v1", "kind": "ConfigMap", "metadata": {"name": "test"}, "data": {"foo": "1"}}' 

I need to interact with K8S API or directly with K8S’s etcd directly if possible (is it?), and I don’t want to rely on resourceVersion. I’d like to depend on my own version which is actually the config map’s data key. How can I achieve such an atomic UPDATE (or DELETE) operation?

user expectation – Can we create Empathy Map without creating Persona?

I am new to this UX industry. I have a task with a brief to create an Audiobook app experience & to map out and simply describe what will be your end-to-end design process to tackle this problem.

As of now I am not able to find out Prospective users to interview for this concept so , I’m thinking that I can create Empathy map by visualising as a User & move forward with User flow diagram.

So here are 2 questions:

  1. What’s the best creating combination of Artefacts to describe End-to-end design process ? Like , Problem statement, Solution , Empathy map , user flow diagram , IA etc ?
  2. Can I directly create Empathy map without creating Persona ?

Any help would be appreciated!

ag.algebraic geometry – the map on divisor class groups induced by restriction to a toric subvariety

Let $X$ be a (say, complex) toric variety acted upon by a torus $T$ and defined by a fan $Sigma$ in the cocharacter lattice $N=mathrm{Hom}(mathbb{C}^times, T)$, and let $M$ be the character lattice. For any cone $sigma in Sigma$ put $M(sigma) = sigma^perp cap M$, $N(sigma) = mathrm{Hom}(M(sigma), mathbb{C}^times)$. There is a natural projection $N to N(sigma)$. Then the closure of the orbit corresponding to $sigma$ has the structure of a toric variety with respect to the quotient torus with the cocharacter lattice $N/N(sigma)$ and given by the fan $Star(sigma)$ consisting of the images in $N(sigma)$ of the cones of $Sigma$ containing $sigma$. Note that the closed embedding $X_{Star(sigma)} to X$ is generally not a toric morphism, since the dense toric orbit of $X_{Star(sigma)}$ does not intersect the dense toric orbit of $X$.

My question is: is there a way to describe the restriction map $mathrm{Cl}(X) to mathrm{Cl}(X_{Star(sigma)})$ in terms of the fans $Sigma$ and $Star(sigma)$?

views – Choose location on a map and add to webform submission details – drupal 8

We’d like to be able to allow a user to pin point a location on a map and then be able store that information with lat and long in a webform submission.

I’ve looked into the add on’s on webform drupal 8 but there doesn’t seem to be any direct integrations to allow this to happen.

Looked into the geofield module with leaflet integration and it does what we want within a content type and allows content managers to choose a location, however, we’d like to get this working for drupal 8 webform. Any leads would be helpful.

Colour scheme for two distinct sets of 5 items on a map

I apologize for the utter simplicity of this, but it is beyond me.

I am using a Leaflet and Leaflet.markercluster to add markers to a map. The latter helps resolve clutter by grouping icons near to each other, which would otherwise overlap.

enter image description here

As you can see from this screenshot, the more markers in a group, the darker – sort of, it runs from dark orange, through yellow to green (there are actually 5 levels). Visit the demo and zoom the map to see how it works.

So far, so good. I have implemented this in my app and when expanded to individual markers, they are either green or blue, with each having a specific meaning.

I also have different set of markers, which are read, and now there becoming enough of them to want to cluster them too.

The red marker is
enter image description here
with RGB value of #982E40 (I use the smaller marker). See here for all leaflet markers.

There are a total of five zoom levels, governed by CSS, depending on how “big” the group is (how many markers it represents).

Finally, a question: which RGB values, dark to light, should I use to represent the second set of circular cluster groups (notice that the circles actually have a darker centre, with a lighter surround) in order to distinguish them from the others.

I want to have two visually different groups of clusters. I am capable of making each group a single colour, no matter how markers it contains. I am not capable of making the five levels of each both distinct and visually appealing.

Hmmm, maybe I want to use that outer circle and make it either green or red, irrespective of the centre colour? Also, the default uses up to five colours; maybe that ought to be just 5 shades of green, to compare with 5 shades of red? Note,: I am not married to green & red (the existing groups represent companies and the new one will represent unemployed people).

Also, 2 colours might enough, as the clusters show how many markers they contain. I can see how colours relating to size might help, but might they also confuse?