Julia: Flattening array of array/tuples

Iterators.flatten(x) creates a generator that iterates over each element of x. It can handle some of the cases you describe, eg julia> collect(Iterators.flatten([(1,2,3),[4,5],6])) 6-element Array{Any,1}: 1 2 3 4 5 6 If you have arrays of arrays of arrays and tuples, you should probably reconsider your data structure because it doesn’t sound type stable. However, … Read more

Check if a value is in an array or not with Excel VBA

You can brute force it like this: Public Function IsInArray(stringToBeFound As String, arr As Variant) As Boolean Dim i For i = LBound(arr) To UBound(arr) If arr(i) = stringToBeFound Then IsInArray = True Exit Function End If Next i IsInArray = False End Function Use like IsInArray(“example”, Array(“example”, “someother text”, “more things”, “and another”))

Get the first element of list if it exists in dart

UPDATE: since Dart 3.0, package:collection is no longer required to use method firstOrNull. Thanks to @Mrb83 for pointing this out. Now you can import package:collection and use the extension method firstOrNull import ‘package:collection/collection.dart’; void main() { final myList = []; final firstElement = myList.firstOrNull; print(firstElement); // null }

Yii model to array?

I’m going on the assumption here that you only need to retrieve just the bare arrays, and not any associated model objects. This will do it: $model = Trips::model(); $trips = $model->getCommandBuilder() ->createFindCommand($model->tableSchema, $model->dbCriteria) ->queryAll(); This is like the Yii::app()->db->createCommand(‘SELECT * FROM tbl’)->queryAll(); examples, except: It’ll ask the model for the table name; you won’t … Read more

Multiple files upload (Array) with CodeIgniter 2.0

I finally managed to make it work with your help! Here’s my code: function do_upload() { $this->load->library(‘upload’); $files = $_FILES; $cpt = count($_FILES[‘userfile’][‘name’]); for($i=0; $i<$cpt; $i++) { $_FILES[‘userfile’][‘name’]= $files[‘userfile’][‘name’][$i]; $_FILES[‘userfile’][‘type’]= $files[‘userfile’][‘type’][$i]; $_FILES[‘userfile’][‘tmp_name’]= $files[‘userfile’][‘tmp_name’][$i]; $_FILES[‘userfile’][‘error’]= $files[‘userfile’][‘error’][$i]; $_FILES[‘userfile’][‘size’]= $files[‘userfile’][‘size’][$i]; $this->upload->initialize($this->set_upload_options()); $this->upload->do_upload(); } } private function set_upload_options() { //upload an image options $config = array(); $config[‘upload_path’] = ‘./Images/’; … Read more

Go slices – capacity/length?

All your variables have a slice type. Slices have a backing array. In Go you can’t access uninitialized variables. If you don’t explicitly provide a value when you create a new variable, they will be initialized with the zero value of the variable’s type. This means when you create a slice with make([]int, 0, 5), … Read more

tech