unity – Instantiate from two values, each in separate array

I have a problem with Instantiating GameObjects from floats in arrays, which I have to merge into one Vector2 (or Vector3). I have only two values in arrays:

GameObject = somePrefab
float() = value1
float() = value2

First I have to combine them into a vector, then Instantiate as many prefabs as the combined vector number is…

Can anybody help me with how to merge these floats into a vector and instantiate?

data structures – Reverse An Array whats wrong with this type of code?

data structures – Reverse An Array whats wrong with this type of code? – Computer Science Stack Exchange

python – cambiar un array a list ocupa más memoria

quisiera saber si al momento de tener un array y lo convierto en list, el array se elimina o aun queda ocupando memoria. Por ejemplo:

Array1 = np.array((1, 2, 3, 4, 5))
Array1 = Array1.tolist()

Cuando cambio el Array1 a lista, ¿el array se borra y ahora ocupa memoria la lista?

Cognito Forms: Selecting Individual Items From an Array

I have created an array, using the .Split() functionality, I would like to now reference each item (it I believe) in that array, specifically.

How do I achieve that?


The rest of this you don’t need to read, but I’ll try to provide more information.

I am now going to use an example of something that I might like to do, this is not literally all I want to do.

So. Let’s say a user has input the following data in to the ‘Inputta‘ field:

aaa#bbb#ccc#ddd#eee#fff

Now, in the ‘Arraya‘ field, I have:

Inputta.Split("https://webapps.stackexchange.com/#")

Let’s say I would like to select the “ddd” entry in that array, how would I do that?

I’ve tried using the .Where() functionality, eg: “.Where(ItemNumber = 4)“, but even if that did work (it doesn’t), it would be no use for if I need to be iterative.

I’ve tried to play with the .Select() functionality, but that’s not helpful, either, as I can’t find decent information on how it even works.


So, on to that iterative tip, to build on this example, I have a secondary requirement of the form, which is to pick an item from the array from an incremented integer.

We’ll imagine I know how to increment an integer, and have that information already, either in a separately generated .Split() field, or as an integer calculation in a Repeating Section.

How would I use the integer to find the array entry in the ‘Arraya‘ field?

Basically, how would I select item 1 (from the second array), then item 2, etc?

This isn’t a separate question, I’m just explaining further the requirement.


As an addendum, I’d love to know how to create an array of incremental integers leading to a pre-determined max number. 😉


For the record, I have StartPaged this thoroughly.

  1. I can’t find a full reference chart for the functions available anywhere online.
  2. The list on CF only lists a subset of the available functions (for example, the .Select() array functionality is not listed)
  3. Everywhere else appears to handle other specific functions.

None of that is stated to cast any disdain anywhere, purely to indicate that I have looked, perhaps my StartPage Fu is just not that strong. Either way, apologies for asking here.

compile – Improving large array manipulation

I am doing an iterative program, which uses large arrays/vectors and where the output of one round is used as an input for the next steps but works slowly when dimensions are bigger.
In brief, we create firstly the complex matrix s (dimension dos x dos) using SparseArray

    dos=101;
    s = SparseArray({{i_, i_} :> 1. + I, Band({2, 1}) -> 2., 
    Band({1, 2}) -> 2., Band({dos + 1, 1}) -> 2.0, 
    Band({1, dos + 1}) -> 2.0}, {dos*dos, dos*dos}, 0.);

And initial condition

    input=ConstantArray(1,{dos,dos});
    input=Flatten(input);
    u1=input;

And finally, we do the iterative steps following some conditions/rules related to which position in the array is used

    lr = Table(i, {i, 1 + dos, dos*dos - dos, dos});
    ll = Table(i, {i, dos + dos, dos*dos - dos, dos});
    lt = Table(i, {i, 1, dos, 1});
    lb = Table(i, {i, dos*dos - dos + 1, dos*dos, 1});
    lll = Sort(Join(lr, ll, lt, lb)); (*rules*)
    
    steps=50;
    Do(f = SparseArray({{i_} :> 
       If(MemberQ(lll, i), 
        0, -2.0*u1((i - 1)) - 2.0*u1((i + 1)) - 2.0*u1((i + dos)) - 
         2.0*u1((i - dos)) + (1.+I)*u1((i)))}, {dos*dos});
    u1 = LinearSolve(s, f);, {j, 1, steps, 1})

This takes around 15 sec on my computer but with increasing dimensions, the time needed grows quickly. I noticed that applying LinearSolve is not slow, but creating the array f is where almost all the time is consumed. Is there a way to create f more efficiently? I tried to use Compile but not good results. Thanks in advance

asymptotics – Searching in sorted array with $O(log n)$

Recently been practicing some recent exams, there was a problem I could not comprehend the given answer, the question is as follows:

Suppose array $A(1..n)$ consist of $n$ distinct integers that is
sorted in ascending order, then How many of below problems could be
solved in $O(log n)$?

and there were three statements;

  • Find an $i$ index so that $A(i)= i $
  • Find an $i$ index so that $A left lfloor{i}right rfloor = 3i +2$
  • Find an $i$ index so that $A(i)= 4i^{2} + 3i + 5$

The answer sheet stated as one statement is true, Also there was no clue on which statement is true.


What is my issue?

So I think the first and second statements could be true, since the array is sorted then we can use Binary search with $O(log n)$ to find the element with index $i$, also the first two statements are linear, thus I think that’s what the question wants, If it’s not then I don’t know what the question exactly wants, any explanation would be handful.

database – How to access array element?

I have the following array:
Array
(
(1) => DrupalnodeEntityNode Object
(
(in_preview) =>
(values:protected) => Array
(
(nid) => Array
(
(x-default) => 1
)
(vid) => Array
(
(x-default) => 19
)
(type) => Array
(
(x-default) => mak
)
(uuid) => Array
(
(x-default) => d3129b72-d115-458e-9a5e-28f23ce5d9a4
)
…….

How can I access nid from this?

php – how can make looping array to be one array with simple code

i want make my looping data in one array without index. i had solve it with code above but i think it so crowd and not simple

this my code

$data = array();
while($dt = $this->db->fetchAssoc($res_weight)){
    $data() = array_values($dt);
}
$datas = json_encode($data);
$datas = str_replace("(","",$datas);
$datas = str_replace(")","",$datas);
$datas = '('.$datas.')';
$datas = json_decode($datas);

how can i make this code more simply then this code

array – Llamada GET siempre me trae una colección, ¿cómo hacer para traer 1 recurso por separado?

No puedo hacer que la respuesta que hago a una API sea “única”, en vez de devolverme un sólo recurso me trae una colección y necesito ver sólo un recurso.

  1. En mi controlador PlayVideosController hago una llamada hacia una API en donde le agrego una variable $id al parámetro de mi función, esta busca en la API la columna de _id, luego la guardo en una variable que guarda un array.
    public function thps4($id)
    {
        $id++;
        $thps4Videos = Http::get('http://thvid-api.herokuapp.com/videos/game/THPS4/$id/1')->json();
    
        $thps4Video = $thps4Videos(0);
        return view ('videos.thps4', compact('thps4Video'));
    }
  1. Esta información la paso a un componente de Livewire en donde realizo un forelse, y dentro tengo un <a href="">, aquì le paso el $key para poder seleccionar un recurso, esto como resultado me genera una URL asi: http:://thpsvido.com/videos/thps4/4
<div wire:init="loadTHPS4">
    <div>

        @forelse ($thps4Results as $key => $thps4)
            <div wire:key="results-{{ $thps4('_id') }}">
                <img src="{{ $thps4('Thumbnail') }}">
                    <div>
                        <a class="relative bottom-4" href="videos/thps4/{{ $key }}">
                            <svg>
                            </svg>
                        </a>

                        <p class="text-sm font-semibold ml-14">
                            {{ $thps4('Title') }}
                        </p>
                    </div>
            </div>
        @empty
            @foreach (range(1,6) as $thumbnail)
                <div wire:key="empty-{{ $thumbnail }}">
                    <p>cargando...</p>
                </div>
            @endforeach
        @endforelse
    </div>
</div>
  1. Al hacer clic en el href uno es redireccionado a otra página en donde existe un elemento de tipo <video>, y utilizando una librería, VideoJS hago que se carge un video de Youtube. Es en las propiedades de la librería en donde escribo la dirección, y aquí en la dirección: reemplazo el ID del video de youtube con la variable que tengo en mi controlador. Aquí, la variable de $key ya tiene que haber asociado la posición de un array, con la columna ID. Y esto debería de suceder para todas las arrays, obteniendo un video con un ID diferente.
    <div class="pt-20 h-full w-screen">
        <video
            id="vid1"
            class="video-js"
            controls
            autoplay="true"
            preload="auto"
        >
      </video>

        <div
            x-data="{close: true}"
            x-show="close"
            class="text-center"
        >
            <p class="text-sm text-gray-500">
              Mute is enabled by default, sorry for the inconveniences
            </p>
            <p 
                x-on:click="close = false"
                class="text-green-500 text-sm cursor-pointer"
            >
                close
            </p>
        </div> {{-- inconveniences message --}}

    </div>
    
    <!-- videojs -->
    <script src="//vjs.zencdn.net/7.10.2/video.min.js"></script>
    <script src="{{ asset ('/js/Youtube.min.js') }}"></script>
    
    <script>
        var player = videojs('vid1', { 
            "techOrder": ("youtube"), 
            "sources": ({ "type": "video/youtube", 
            "src": "http://www.youtube.com/watch?v={{ $thps4Video('ID') }}"}),
            "fluid": true,
            "autoplay": true
        });
        player.ready(function() {
            setTimeout(function() {
                player.autoplay('muted');
                player.volume(0.5);
                player.fluid('true')
            }, 2000);
        });
    </script>

Dependiendo de la URL, un video diferente se debería de cargar cada vez que se hace clic, ya que si la URL es la siguiente http:://thpsvido.com/videos/thps4/4 entonces deberíamos de cargar sólamente un video, y ese sería el que esté en la posición 4. Otro ejemplo, si la dirección es la siguiente: http:://thpsvido.com/videos/thps4/5, entonces debería de devolver el de la posición 5.

No importa cual sea el número que aparezca en la URL, por ejemplo, puede ser: http://thvid-api.herokuapp.com/videos/game/THPS4/$id/2, aquí se cargan 2 videos debería de ver sólamente 1, el de la posición 2.

Si hago un dd($thps4Videos) en mi función y le doy clic al video que sea, siempre me devuelve el mismo video en el array.

Un array dentro de la colección tiene estas columnas:

array:1 (▼
  0 => array:8 (▼
    "_id" => "605a43ea667cd39060f435ac"
    "Title" => "THPS4 Rewind: Summer Of 2003 Unreleased (Edited by Maxfli)"
    "Game" => "THPS4"
    "ID" => "Qxd7D1KN1No"
    "Thumbnail" => "https://i.ytimg.com/vi_webp/Qxd7D1KN1No/maxresdefault.webp"
    "newduration" => "00:22:53"
    "category" => "gameplay"
    "updatedAt" => "2021-04-12T17:45:27.167Z"
  )
)

No tengo ningun error en cuanto a excepciones o mensajes de error.

Estoy utilizando una librería Javascript llamada VideoJS, versión 7.10.2, estoy usando Mozilla Firefox en Windows 10. También estoy utilizando la extensión de Youtube de esta misma librería.
VideoJS: https://github.com/videojs/video.js
Youtube extension: https://github.com/videojs/videojs-youtube

La API recolecta estos datos de Youtube.

pygame – How do I click on specific text in an array of text?

I am trying to click on a specific word in an array but I can’t think of how.

This is what I have:

  for x in range(0, len(names)):
    templine = font.render(names(x), True, WHITE)
    tempRect = templine.get_rect()
    tempRect.midleft = (50, (170+30*x))
    if mouse012(0) == True and tempRect.collidepoint(mouseXY):
      state = AppState.STATS

      detailsName = names(x)
    screen.blit(templine, tempRect)

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive Proxies-free.com New Proxy Lists Every Day Proxies123