yeah, trying to apply the idea unreasonably beyond its intent.

Thanks for the replies folks.
 
On Sunday, June 25, 2017 at 2:52:00 PM UTC-4, Alexis King wrote:
> As written, the simple answer to your question is to use begin0 or
> begin, depending on if you are using ~> or ~>>.
> 
>     > (~> 3 (begin0 (displayln "hi!")) (* 2))
>     hi!
>     6
> 
> But as Greg mentions, this is not very useful, and it probably isn’t
> what you want, since the evaluated expression can only be evaluated for
> side-effects, which is rather against the spirit of threading macros
> altogether.
> 
> It is a little difficult for me to imagine what a hypothetical syntax
> for your use-case would look like without turning ~> into a much more
> complicated binding form. As it is, the threading macros are all quite
> simple, and they are simple shorthands for syntactic nesting. It would
> be possible to generalize them quite a bit, but I am fond of their
> simplicity, and I think Greg’s suggestion to just use let* is a good
> one. I’m not sure there is a good way to synthesize the brevity and
> simplicity of threading with a more powerful binding form, though if you
> can come up with a syntax that accomplishes what you’re getting at, I’d
> certainly at least be interested by it.
> 
> > On Jun 25, 2017, at 09:44, Sanjeev Sharma  wrote:
> > 
> > is there a way to do a calculation in the middle of the chain that
> > takes no arguments?  In other words, exempt some operations in the
> > chain from taking any arguments.
> > 
> > Suppose one's doing a calculation of interest earned on an investment
> > and one is threading a running balance through the chain, but at
> > places one needs a calculation for purchases and/or dispositions to
> > the investment.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to