« first day (580 days earlier)      last day (3921 days later) » 

1:06 AM
Is there an easy way to change the remove of the context in a held expression?
For example
P`y[P`y[P`a P`b]]
should become
y[y[a b]]
Is there an easy way to change/remove the context of variables and functions in a held expression?
This works
Replace[
 Hold[P`y[P`y[P`a P`b]]]
 , {x_[t___] :>
   With[{new = SymbolName[x]},
    new[t] /; True],
  x_Symbol :>
   With[{new = SymbolName[x]},
    new /; True]
  },
 Infinity]
But I figured there might be a more generalized way. It isn't to long it could be worse.
sorry replace SymbolName[x] with Symbol[SymbolName[x]]
 
1:40 AM
@Liam Aren't you probably attempting to do (whatever it is you are trying to do these days) something that exceeds your Mathematica knowledge by too much? Perhaps you should start with simpler challenges?
All symbols belong to a context and there's nothing you can do about it. A different story is how they show up
 
2:02 AM
@Rojo Easy challenges, that's no fun. ;) I have a final goal in mind and I simple working through the issues as they come. I managed to came up with a working answer. ;) I do sometimes wonder if there might be a better solution in cases like the one above.
 
2:44 AM
@Liam sure, but
it seems to me that your question is flawed already from the start
so I wonder if you really profit from trying to find an answer as is
 
3:12 AM
@Rojo I am happy to explain what I am ultimately trying to do, to see if you know a better a technique. You see I am working through issues as they appear. Yes I don't agree with everything but I mean if it works.
 
 
2 hours later…
4:49 AM
Not all my questions have been completely out in left or right field. Both of my clipboard questions I believe were helpful/useful for the community.
 
 
6 hours later…
10:48 AM
Quick and dirty: ToExpression[
StringReplace[ToString[P`y[P`y[P`a P`b]], InputForm], "P`" -> ""]]
@Rojo The FrontEnd sometimes generates $$CellContext` contexts and if you want to manipulate generated notebooks programmatically this can drive you nuts ...
I wished the FrontEnd actions w.r.t to context (generation) would be documented. Probably too time consuming (or did I overlook it?)
 
 
1 hour later…
11:59 AM
@RolfMertig Agree. The Front End isn't too documented anyway. Perhaps they feel a lot can be changed in the future
@Liam Definately
That's not what I meant
Anyway, Rolf solution works so hope it is helpful
An alternative could be
SetAttributes[removeContexts, HoldAllComplete];
removeContexts[code_] := Module[{tag},
  SetAttributes[tag, HoldAllComplete];
  DeleteCases[
   Unevaluated[code] /.
    s_Symbol :>
     Block[{},
      ToExpression[SymbolName@Unevaluated@s, InputForm, tag] /; True],
    tag, {0, Infinity}, Heads -> True]
  ]
Just remember we are not really "removing" a context but changing it to another one
 
12:42 PM
2
A: How can I return private members of a Mathematica package as the output of package functions without the "PackageName`Private`" prefix?

rm -rfThe only way to call a function/variable in a package without using the full context is to make it public, which is typically done with usage messages immediately after the BeginPackage["Package`"] and before Begin["Private`"]. To me, it seems like you just want to be able to view the definition...

There's also this:
5
Q: Delete contexts from a string representation of a symbol

Faysal AberkaneI want to delete the string representing the context of a symbol. For info I need such a functionality in my ShowIt function defined here I'd like to know how I can replace such a string with a rule so that for example, "MyFunc[ShowIt[Q1`Private`var1$123], ShowIt[Q2`Private`var2$456], 0., 1.]"...

@MichaelE2 Are you around?
 
Does anyone know what Value is?
not up- down- own-,
just `Value`
encountered reading someone else's code where they set a_\[LongRightArrow]b_:=Value[a]=b
 
1:03 PM
Was it on this site?
I don't know what value is, and it's undocumented... I would be tempted to guess it's a dummy head used internally, but I don't know
 
nope, not on this site.
But, you're right, it is just a dummy head I think
 
1:43 PM
@rm-rf I am now
 
2:20 PM
Hello everyone
@rm-rf are you around?
 
2:38 PM
@MichaelE2 I guess I missed you again... In any case, I wanted to ask if you answered (or recall) a question on plotting stream lines if given the direction of the stream at each grid point. That's sounds like something you or Jens would've answered
@Sosi I am now
 
@rm-rf I'll have to check.
 
@rm-rf I was going to ask you some more questions about what we were discussing yesterday, but I'll post it as a new question instead. I think it is worth it ;)
 
@Sosi Hi Sosi!
 
@MichaelE2 hey Michael! How's it going?
 
7
A: How do I draw lines perpendicular to contour lines on ListPlot3D?

Michael E2One can do what you ask, but you might prefer to follow the advice of @Jens. Here's how, anyway. First, I made up some data for a similar potential function. data = Table[10 + (3 ((20 - j)^2 - (j + 5)^2))/(75 + (i - 10)^2 + 2 (j - 10)^2), {j, 0, 20}, {i, 0, 20}]; f = ListInterpolation[dat...

Not exactly the same, perhaps
 
2:41 PM
@Sosi Alright
 
@Sosi It ok. We've had several days of rain. Usually we have drought.
@rm-rf Sounds like a straightforward ListStreamPlot.
 
@MichaelE2 Not really... Hold on, I'm grabbing some data for you to view now
 
I'm trying to do this:
a = Table[{x, 0}, {x, 1, 10}];
b = Table[{x^2, 10}, {x, 1, 10}];

n = 1;
l = {Line[a], Line[b]};

While[n >= Length[a],
AppendTo[l, Line[{{a[[n]][[1]], 0}, {b[[n]][[1]], 10}}]]; n++]


Graphics[l]
But it's not appending lines to the given list.
Why is that?
 
@MichaelE2 The problem is that it's not a field... well, the underlying process is, but the data is only for the dominant direction, so there's large swathes of constant direction and others that are more messy and discontinuous
 
@rm-rf A brain toad! That's nice!
 
2:46 PM
:)
@MichaelE2 For example, see this (use Hue)
Oh, and do -1 -> Indeterminate (I couldn't upload it with Indeterminate because it exceeded the file limit imposed by pastebin)
 
@rm-rf OK
 
@MichaelE2 where are you at? Germany?
@rm-rf If you could please check this out I would appreciate a lot!
 
@Sosi Ok, I will... do you need it right now or can it wait a bit (bit == few hrs)?
 
Of course!
I can wait ;)
 
Alrighty! :)
 
2:54 PM
@rm-rf I'm a little confused: There seems to be a grid of scalar values. How do they represent directions?
@Sosi Georgia (USA)
 
@MichaelE2 Degrees from 0 (North) divided by 360
 
@MichaelE2 Oh! I was in Atlanta in May!
Went to a conference at Georgia Tech
 
@GustavoBandeira Is the inequality backwards on While?
 
@MichaelE2 OMG...
I'm so stupid.
Thanks.
 
@GustavoBandeira :D
@rm-rf What if -1 is mapped to {0, 0}, and the others to {Cos[#], Sin[#]}? Perhaps ListStreamPlot will handle the discontinuities gracefully.
 
3:06 PM
@MichaelE2 That's a much better suggestion than anything I've tried! But LSP complains that it's not a valid vector field
(it isn't)
Thanks though, I'll try some caveman techniques which might be faster to code up... this is rather a small detail that would've embellished the plot, but I can live without it :)
 
Just a sec
(* data = pastebin stuff *)
back = ArrayPlot[data, ColorRules -> {-1 -> Darker@Green, _ -> White}];
data2 = data /. {x_ /; x >= 0 :> {Cos[2 Pi x],
      Sin[2 Pi x]}, -1 -> {0., 0.}};
Show[back,
 ListStreamPlot[Transpose@Reverse@data2, StreamPoints -> Fine]]
@rm-rf No complaints (error messages). Maybe it's my version.
A few minor land/sea boundary issues
 
@MichaelE2 Thanks! And I saw why my try didn't work... stupid mistake :)
 
@rm-rf You're welcome. :)
 
3:44 PM
I would appreciate a lot if you guys could give a look into this and suggest something! Thank you so much!
 
 
2 hours later…
5:41 PM
@Sosi Is 1/cond1a+cond1b+cond1c+cond2a+1/cond2b+cond2c your actual objective function or something you just used? Is your actual goal to find any k1, k2 that will satisfy your constraints? If so you could just use a dummy obj. fun
 
6:21 PM
@rm-rf Oops, perhaps it ought to be {Sin[2 Pi x], Cos[2 Pi x]} is 0 is due N and and 0.25 is due E.
 
@MichaelE2 That's ok, I fixed that :) I just needed to get the LSP running
 
 
2 hours later…
8:34 PM
As far as I can see Mathematica is only capable of riemann integration
 
 
3 hours later…
11:28 PM
I am making a new demo on finite differences, here is what it will do: 1. select function to approximates its derivatives(s), supports up to 4th. 2) select from menu either centered, forward or backward, 3) select point x to expand around, 4) select how small to make h. Then the demo will generate table of approximations, the finite difference formula itself, and other plots..... Am I missing something more to make this more useful?
The menu will have few pre-defined functions (like sin(x), etc...) since it is not possible to allow user to type in their own function. Will try to include few interesting ones. The order of finite difference can be up to 9. This is more than anyone will ever need.
 

« first day (580 days earlier)      last day (3921 days later) »