Ali Hashmi
• Member for 6 years, 10 months
• Last seen this week

you can do something like this: data=Import@"C:\\ Users \\ Ali Hashmi \\ Desktop \\ file.dat"; (* {{}, {1, 2}, {3, 4}, {5, 6}, {}, {11, 22}, {33, 44}, {55,66}, {}, {22, 33, 44}, {55, 66}, {}, {}, {2, ...

I found that the system has the tendency to generate results provided that the system is not too undetermined. for instance if we use the grid (same as above but with slightly fewer unknowns) and ...

ToExpression[ StringReplace["[[1 4 5 6 2] [9 8 7 4 7]]", {" " -> ",", "[" -> "{", "]" -> "}"}]] (* {{1, 4, 5, 6, 2}, {9, 8, 7, 4, 7}} *)

@LouisB and I have propose the following solution Transpose /@ ArrayReshape[Transpose@{Aa, Bb, Cc}, {3, 3, 3}] or ArrayReshape[Transpose[Flatten /@ {Aa, Bb, Cc}], {3, 3, 3}] and as mentioned by @...

Here is a partial attempt to make your code faster. I would suggest the use of ParallelTable and SortBy rather than Sort. Perhaps in your case there is no need to use IntervalMemberQ and Interval. ...

list = (RegionIntersection[\[ScriptCapitalR]2, #]&/@ MeshPrimitives[\[ScriptCapitalR]1, 1] //Cases[#, Point[arg_] :> arg] &); trimList[ls_] := Module[{p = ls, pairs, firstelem = First@ls, ...

Clear@fun; fun[n_, l_] := Plus @@ Function[x,Times @@ (n^x)] /@ (Select[Tuples[ Range[0, l], {Length@n}], Total@# == l && Length@# == Length@n &]) fun[{p, q}, 4] (* p^4 + p^3 q + p q^3 + ...

This is the most general solution i could conceive. added the SameQ test in Complement to get lines outside the region as well Module[{module, lines, points, area, region, memberpoints, ...

function8[data : {{_, _} ..}, min_,max_] := (Mean[data[[All, 2]]] /; AnyTrue[{Min[data], Max[data]}, IntervalMemberQ[Interval[{min, max}], #] &]) function8[data : {{_, _} ..}, min_, max_] := "No ...

(* a crude way: lets assume we wish to find all the permutations of a list of three integers that add up to 4 *) Select[Permutations[Flatten@ConstantArray[Range[0, 4], 3], {3}], Plus @@ # == 4 &]...

Map[(Total[#]/Length[#]) &, #] &@{{{10, 34}, {9, 32}, {9, 33}}, {{5, 18}, {3, 20}}, {{16, 21}}, {{20, 33}}, {{21, 18}}, {{6, 26}}, {{23, 22}}, {{15, 35}}, {{19, 26}}, {{24, 12}}, {{22, 25}}, {{...

I thought about a scheme to perform two most important operations on the image mask i.e. delete edges (in over-segmented regions or incorrect edges) or add edges (in under-segmented regions) with a ...

I am marking this question as a duplicate since you have asked a very similar question before. However, below is what you need to implement. The counter will count the number of times the value is ...

Based on the earlier suggestion: i = Import@"https://burnersxxx.files.wordpress.com/2013/08/einsteintongue.jpg" Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, PlotStyle -> Texture[i], Mesh -> ...

I am not sure why you are assigning probabilities if according to you - and correct me if i am wrong - a point could just randomly be selected. I think you need a Metropolis Acceptance Criterion for ...

here i am modifying the answer given by @kglr slightly to find both the maximum and the minimum cost path. pathMatrix[matr_, Oper_: Max] := Module[{sum, nextF, i, j}, With[{dim = Dimensions@matr}, ...

ClearAll[addDownValuesRuntime, f] str = "p"; int = 5; (* global values defined to test if our code binds the definition to function f without evaluating these OwnValues *) SetAttributes[...

I constructed a method to overcome the issue: SetAttributes[table, HoldAllComplete]; table[body_, tail_] := Module[{p, q, sym = Unique["x"]}, {p, q} = Map[(Hold[#] /. x_ /;(Developer`HoldSymbolQ[x] ...

if order does not matter: Attributes[f] = {Orderless}; f[x__Integer, __] := {x} f @@ {3, 5.6, 8.19, 2, 5.6, 4, 3, 8.5, 4.137, 7., 1.165} (* {2, 3, 3, 4} *)

Map[ Reverse@Array[a, #] //. {a[x_], p : Repeated[a[_], {2, Infinity}]} :> {a[x], {p}} /. List :> f &, Range[5]] (* {a[1], f[a[2], a[1]], f[a[3], f[a[2], a[1]]], f[a[4], f[a[3], f[a[2], a[...

you can also do this: Inner[Set, Most@variables, Most@values, None];

A HeadStart by no means it is a complete answer. But one can surely play around with it a bit img2 = MorphologicalBinarize[GaussianFilter[BrightnessEqualize[img], 2], 0.44] // Opening[#, 2] & // ...

you can also do something like this: f[arg__][p_] := p @@ {arg} Through[{f[1, 2], f[Sin[x], Cos[x], 4, 7]}[List]] (* {{1, 2}, {Sin[x], Cos[x], 4, 7}} *)

Loops are not usually needed in Mathematica to solve problems. Functional Programming and Patterns can do job more efficiently m = {-1, -3, -2, -5, -4}; {Flatten@#, Extract[m, #]}\[Transpose]&@...

Map[Cases[__?(StringLength[#] >= 2 &)]][data] Map[Cases[x__/;StringLength[x] >= 2]][data]

ClearAll@completePartitions; completePartitions[list1_, list2_] := Module[{permute, possibleCombinations, flattenedComb, func, listinplace = list1, pick}, permute = Subsets[list1, All]; ...

This will delete all entries with zeros: t = Table[a -> RandomInteger[{-9, 9}, 3], {50}]; DeleteCases[t, HoldPattern[a -> p : {__}] /; MemberQ[p, 0]] also this will replace entries where zeros ...

constructPairs[input_] := Block[{func, f, list1, permutepart, list2}, func[x[t_]] := t; func[x[t_]^m_] := ConstantArray[t, m]; list1 = Flatten[Map[func]@Cases[input, p : (t_x | x[_]^_) :> p]]; ...