New answers tagged

2

This too does the same thing: Button[#, f[#]] & /@ Range@2 Also an ugly but stupid way: Table["Button[" <> ToString@i <> ",f[" <> ToString@i <> "]]", {i, 2}] // ToExpression One can write it down without thinking.


4

You can use With Table[With[{i = i}, Button[i, f[i]]], {i, 1, 2}]


0

Build a Table of segments and display the desired number of segments. surf[u_, v_] := {Cos[ u] (16.958793136378254` E^(0.16568669119550355` u) + \ (1.2436985521695564`*^-15 + 8.299999999999999` E^(0.16568669119550355` u) + 0.34091663610461015` Sqrt[ 8.881784197001252`*^-16 + 5.927385595690565` E^(0.16568669119550355` ...


0

Trials Trial 1. Failures in trying to remove vertices fom HararyGraph. The structure is not preserved for which SetProperty (?) and the repetitive assignment after each removal failing -- the table below removes the other vertex from new graph not from the one where one vertex was already removed. Trial 2. Failure in trying to remove vertices ...


0

The problem you are facing is similar to the one described in this post. The neat solution would be to remove Dynamic everywhere and wrap the whole code in Manipulate (see my version below). It works well and hopefully as you intended. Manipulate[ Positions = 10; AngleStep = (2 Pi)/Positions; AB = EuclideanDistance[{pA[[1]], pA[[2]]}, {pB[[1]], ...


1

Confirmation rather than answer. I'm not sure the original example is entirely functional, at least it was not for me. Mine is... SetDirectory["F:\\Temp"]; (* Adjust to suit your environment *) hist = Histogram[RandomVariate[NormalDistribution[0, 1], 10000], ScalingFunctions -> "Log", ImageSize -> 600] Note log scale on y-axis in resulting ...


2

Not a complete answer, but it may help to illustrate some of this behavior. If I run the simple example, Dynamic[Refresh[TableForm[{"ind2=", ind2, "j=", j}], UpdateInterval -> 1]] j = 0; num = 100; SetSharedVariable[j]; ParallelTable[ind2^2; Pause[2]; j++, {ind2, 1, num}] I find that Dynamic does not display ind2. It does, however, display j, which ...


1

I decided to do this in the old-fashioned procedural way. collatz[k_Integer?OddQ] := 3 k + 1 collatz[k_Integer?EvenQ] := k/2 collatzIter[k_ /; k > 2, n_: 125] := Module[{i = 0, c0 = k, c1}, While[++i < n, c1 = collatz[c0]; If[c1 < 2, Break[]]; c0 = c1]; {i, c1}] Module[{m = 2, r = {0, 0}}, While[r[[2]] <= 4, r = ...


4

There are many questions about the Collatz sequence on this site, for example here. I interpret your question to ask for the smallest integer n that, after 125 iterations, has not settled into the 4-2-1 loop that is conjectured to terminate all Collatz iterations. You can run 125 iterations and return the result with the following definition. ...


3

Most of your time is spent in defining PolarCoords. Let's take a look at your code. It looks like you've tried to optimize it already. Let's try to simplify it first: PolarCoords = Map[Function[i, ToPolarCoordinates /@ newCoord[[i]] /. {x_, y_} /; y < 0 -> {x, y + 2 \[Pi]}], Range@Length@pts] Simpler: PolarCoords = ...


3

If you use float instead integer you can reduce the computing time. data = RandomInteger[{1, 400}, {5000, 2}]; c = 10.; r = 60.; pts = c + r {Cos[#], Sin[#]} & /@ Range[0., 2. π, 2. π/16.]; newCoord = Table[(# - pts[[i]]) & /@ data, {i, 1, Length@pts}]; PolarCoords = Table[ToPolarCoordinates[#] & /@ ...


0

Thanks to all of you. In the end I had to tweak the code a little to: myList := Map[# {vxstep, vystep} &, myList, {2}] in order to avoid protected tag issues in a dynamic module. But the script is running smoothly now!



Top 50 recent answers are included