12

This looks nicer in a Notebook: Join[d1\[Transpose], d2\[Transpose]]\[Transpose] Unfortunately transposing a Dataset is very slow. Gordon Coale's alternative is much faster, but the original Dataset@Join[Normal@d1, Normal@d2, 2] is more than an order of magnitude faster than that.


9

This is fugly but fulfils the need of staying in the Dataset domain and is much quicker for large datasets. Basically if we use the analogy of a dataset being a SQL table - I do what I would do in the same situation. Create a dummy key on each, join, then drop the dummy key. Personally for small Datasets I prefer the @Mr.Wizard approach from a readability ...


9

Here's an approach for any two multi-dimensional lists of strings which have arbitrary, but matching structures: stringJoin[x__String] := StringJoin[x] SetAttributes[stringJoin, Listable] stringJoin[La, Lb] EDIT Short explanation of listability: Listable functions are effectively applied separately to each element in a list, or to corresponding ...


9

TL;DR; myArrayFlatten = Flatten /@ Flatten[#, {{1, 3}}] & {x,y,z} or {{x},{y},{z}} is considered column vector. Usage example: v1 = {1, 2, 3}; vNew = {{4, 5}, {6, 7}, {8, 9}}; v4 = {10, 11, 12}; v5 = {13, 14, 15}; v6 = List /@ {16, 17, 18}; { {v1, vNew, v1}, {v4, v5, v6, v1}, {vNew, vNew} } // myArrayFlatten // MatrixForm Flatten approach: ...


8

For trivial combinations, simple Print combinations work well. For more complex operations, take a look at StringForm: var1 = "Tree"; var2 = 10; StringForm["The `1` is about `2` feet tall...", var1, var2] (* "The Tree is about 10 feet tall..." *)


8

I shall assume that you want a compact syntax to make this practical to use. I shall choose cs, standing for compound symbol: cs[x__] := ToHeldExpression @ ToString @ Row @ {x} /. {_[s_Symbol] :> s, _ :> $Failed} func_[a___, Unevaluated @ cs[x__], b___] ^:= ToHeldExpression @ ToString @ Row @ {x} /. {_[s_Symbol] :> func[a, s, b], _ :&...


8

Here are three ways to do it. The first is the best I think: FromDigits@Flatten[IntegerDigits /@ {5, 22, 4, 5}] ToExpression@StringJoin[ToString /@ {5, 22, 4, 5}] ToExpression@StringJoin@StringCases[Characters@ToString@{5, 22, 4, 5}, DigitCharacter]


7

Looks like StringForm can achieve this: Cp = 1.5; deltastar = 0.123; Then: StringForm["The value for `1` is `2` and the value for `3` is `4`.", HoldForm @ Subscript[C, p], Cp, HoldForm @ Superscript[\[Delta], "*"], deltastar]


7

It sounds like you're merely looking for Row: Cp = 1.5; deltastar = 0.123; Row[{ "The value for ", HoldForm[Subscript[C, p]], " is ", Cp, " and the value for ", HoldForm[Superscript[\[Delta], "*"]], " is ", deltastar, "." }] If this does not work for you please clearly state how it fails so that those issues can be directly addressed.


7

This t[1]={1, 2, 3}; t[2]={2, 4, 6}; t[3]={3, 6, 9};t[4]={4,8,12}; tall=Table[t[i],{i,4}] instantly gives you {{1,2,3},{2,4,6},{3,6,9},{4,8,12}} Replace the 4 with 10 or 100 or 1000


7

FromDigits @ ToString @ Row @ {5, 22, 4, 5} Head[%] 52245 Integer


6

First a simpler way to get your first example: (m = ArrayFlatten[Transpose /@ {{v1, v2, v3}, {v4, v5, v6}}, 1]) // MatrixForm An alternative way to do @bill's undoing trick: (m2 = ArrayFlatten[Transpose /@ {{v1, ## & @@ Transpose[vNew]}, {v4, v5, v6}}, 1]) // MatrixForm Using ArrayReshape as an alternative to ArrayFlatten: ArrayReshape[Transpose /@ ...


5

list = {0, 1, 2}; list2 = {0, 0}; Sort[Join @@ (Permutations[Join[list2, {#}]] & /@ list)] {{0, 0, 0}, {0, 0, 1}, {0, 0, 2}, {0, 1, 0}, {0, 2, 0}, {1, 0, 0}, {2, 0, 0}}


5

sLa = Map[ToString, La, {2}]; sLb = Map[ToString, Lb, {2}]; MapThread[StringJoin, #] & /@ Transpose[{sLa, sLb}] also Thread[j @@ #] & /@ Transpose[{sLa, sLb}] /. j -> StringJoin


5

In version 12 Join[d1, d2, 2] seems to work, albeit a bit slower than Szabolcs's Dataset@Join[Normal@d1, Normal@d2, 2].


5

n = 5; Print[ToString[n] <> " trees"]


4

How about just breaking up the matrix and then reconstructing the same way. Here are your source vectors v1 = {1, 2, 3}; vNew = {{4, 5}, {6, 7}, {8, 9}}; v4 = {10, 11, 12}; v5 = {13, 14, 15}; v6 = {16, 17, 18}; So now define and reconstruct: {v2, v3} = Transpose[vNew]; ArrayFlatten[{Transpose@{v1, v2, v3}, Transpose@{v4, v5, v6}}, 1] // MatrixForm If ...


4

I would love this to be uniform for both integer and rational numbers a2 = {2/3, 4/5, 9/7, 3/7, 1.5, 3, 1/9}; StringTrim@StringJoin[" " <> ToString[#, InputForm] & /@ a2] (* 2/3 4/5 9/7 3/7 1.5 3 1/9 *) Row[ToString[#, InputForm] & /@ a2, " "] (* 2/3 4/5 9/7 3/7 1.5 3 1/9 *) StringReplace[ToString[a, InputForm], {"{" | "}" -> "", "...


4

In versions 10.1+, there is also StringRiffle: StringRiffle[list, ""] "Mathematica"


4

Join @@@ Tuples[{Y, X}] {{{2, 6, 8, 2}, {9, 4, 9, 8}, {1, 3, 7, 6}, {2, 1, 3, 2}, {3, 1, 7, 2}}, {{2, 6, 8, 2}, {9, 4, 9, 8}, {7, 7, 1, 8}, {9, 3, 4, 2}, {2, 4, 4, 6}}, {{2, 6, 8, 2}, {9, 4, 9, 8}, {1, 6, 7, 1}, {4, 5, 8, 1}, {5, 5, 7, 3}}, {{1, 7, 4, 2}, {7, 6, 9, 6}, {1, 3, 7, 6}, {2, 1, 3, 2}, {3, 1, 7, 2}}, {{1, 7, 4, 2}, {7, 6, 9, 6}, {7, 7, 1, 8}, ...


4

just try Transpose@{First/@A,First/@B,Last/@A} or Transpose@{A[[All,1]],B[[All,1]],A[[All,4]]} {{3, 6, 5.}, {4, 7, 6.}, {5, 8, 7.}}


4

{## & @@ #[[1 ;; 3]], #[[1]] > 2 b, #[[4]]} & /@ data or {Sequence @@ #[[1 ;; 3]], #[[1]] > 2 b, #[[4]]} & /@ data {{1, 45000., 27500., False, "Inverted"}, {2, 22500., 18333.3, False, ""}, {3, 15000., 13750., False, "Inverted"}, {4, 11250., 11000., False, ""}, {5, 9000., 9166.67, False, "Inverted"}, {6, 7500., ...


4

To get m tables, you can Map the function t on Range[m]: m = 7; t /@ Range[m] {{1, 2, 3}, {2, 4, 6}, {3, 6, 9}, {4, 8, 12}, {5, 10, 15}, {6, 12, 18}, {7, 14, 21}} Alternatively, you can use Array: Array[t, m] {{1, 2, 3}, {2, 4, 6}, {3, 6, 9}, {4, 8, 12}, {5, 10, 15}, {6, 12, 18}, {7, 14, 21}}


3

Starting over I just realized that for the example given we can do this simply with KroneckerProduct: f2[d_, L_] := Range[d] ~KroneckerProduct~ IdentityMatrix[L] // Prepend[#, 0*First@#] & f2[2, 3] (* {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {2, 0, 0}, {0, 2, 0}, {0, 0, 2}} *) f2[86, 99] // Length // RepeatedTiming (* {0.00445, 8515} *...


3

You may use Outer with ArrayFlatten. res = Flatten[Outer[ArrayFlatten[{{#1}, {#2}}] &, y, x, 1], 1]; MatrixForm /@ res Hope this helps.


3

Or StringTake[ToString[a, FormatType -> InputForm], {2, -2}] The inelegant use of StringTake strips off the leading and trailing brackets.


3

IntervalUnion: IntervalUnion @@ (Interval /@ list) /. x_[y__] :> {y} yields: {{1, 2}, {3.5, 11}, {13, 14}}


3

Despite the accepted excellent answer by Mr.Wizard I think it is worth to point out that the standard idiomatic approach to the problem in Mathematica is to use indexed variables: In[1]:= i = 10; d[i] = 30; Definition[d] d[10] = 10; Definition[d] Out[3]= d[10] = 30 Out[5]= d[10] = 10


3

In V10 there is a new function StringTemplate that allows us to build custom formatting functions in a new way. Here is how it can applied to the OP's problem. fmt[args__] := Style[ StringTemplate[ "The value for `1` is `2` and the value for `3` is `4`.", CombinerFunction -> Row ][args], "SR"] cpForm = HoldForm@Subscript[C,...


3

Two options presented themselves to me, using Apply or using replacements: {#1, #2, #3, #1 > 2 b, #4} & @@@ data data /. {x_, y_, z_, p_} :> {x, y, z, x > 2 b, p} Both reproduce your results.


Only top voted, non community-wiki answers of a minimum length are eligible