Tag Info

New answers tagged

5

I think the problem might be related to a bug in FullForm when applied to a ByteArray object: ByteArray["aV+jpGtfd3BHhoSvOthJpQ=="] // FullForm (* List[105,95,163,164,107,95,119,112,71,134,132,175,58,216,73,165] *) The full form has lost information regarding the structure of the ByteArray. The box-form of the button is using this list form but the ...


6

OK, now I have another suggestion: With[{x = ToString[encryptedObj, InputForm]}, Print[x]; Button["Try with", foo = Decrypt["pass", ToExpression[x]]]] The button generates no error and foo is set to "TestCase".


0

In 10.1.0 we have the new function KeyValueMap. You can use these functions, although they are not perfect heldNormal[assoc_] := Apply[Rule, Hold@Evaluate@KeyValueMap[Hold, assoc], {2}] map[f_, assoc_] := Association @@ Unevaluated @@@ List@MapAt[f, heldNormal@assoc, {All, All, 2}] associationMap[f_, assoc_] := Association[ReleaseHold@Map[f, ...


5

Sequence is treated a bit specially. It does not get "evaluated to a result", but instead as the documentation explains: Sequence objects will automatically be flattened out in all functions except those with attribute SequenceHold or HoldAllComplete. This means that even though If has attribute HoldRest, the expression If[1 == 0, x, Sequence[]] will ...


3

Sequence has non-standard evaluation rules. You can work around them like so. seq := Sequence {a, b, If[False, x, seq[]], c} {a, b, c} {a, b, If[True, x, seq[]], c} {a, b, x, c} Updated to conform with the observation made by Szabolcs in his comment below.


1

This kind of problem is the reason I sought and found a solution to: How do I evaluate only one step of an expression? Here is an example of how the step function defined in my answer there is used: var1 = "init-val1"; var2 = "init-val2"; mapping := {var1 -> "val1", var2 -> "val2"} (* note use of := *) step[mapping][[{1}, 1, 1]] % // ...


4

You need to construct your desired expression without unwanted evaluation of its constituent parts. Here is one approach to do that: makeTest[{tests__}] := Replace[And[tests] &, fn_ :> fn[#], {2}] This works because the surrounding Function prevents evaluation before and after the Replace operation. Example: f1[x_] := (Print["First"]; x > ...



Top 50 recent answers are included