Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.advocacy > #489471 > unrolled thread
| Started by | "F. Russell" <frussell@random.info> |
|---|---|
| First post | 2019-03-22 17:38 +0000 |
| Last post | 2019-03-23 20:25 -0400 |
| Articles | 20 on this page of 63 — 12 participants |
Back to article view | Back to comp.os.linux.advocacy
Programming Challenge - Winner Gets Prize "F. Russell" <frussell@random.info> - 2019-03-22 17:38 +0000
Re: Programming Challenge - Winner Gets Prize Steve Carroll <fretwizzer@gmail.com> - 2019-03-22 10:47 -0700
Re: Programming Challenge - Winner Gets Prize "F. Russell" <frussell@random.info> - 2019-03-22 17:56 +0000
Re: Programming Challenge - Winner Gets Prize "F. Russell" <frussell@random.info> - 2019-03-22 18:07 +0000
Re: Programming Challenge - Winner Gets Prize Steve Carroll <fretwizzer@gmail.com> - 2019-03-22 12:11 -0600
Re: Programming Challenge - Winner Gets Prize Melzzzzz <Melzzzzz@zzzzz.com> - 2019-03-22 19:29 +0000
Re: Programming Challenge - Winner Gets Prize owl <owl@rooftop.invalid> - 2019-03-22 19:48 +0000
Re: Programming Challenge - Winner Gets Prize Melzzzzz <Melzzzzz@zzzzz.com> - 2019-03-22 19:51 +0000
Re: Programming Challenge - Winner Gets Prize owl <owl@rooftop.invalid> - 2019-03-22 19:54 +0000
Re: Programming Challenge - Winner Gets Prize Melzzzzz <Melzzzzz@zzzzz.com> - 2019-03-22 19:56 +0000
Re: Programming Challenge - Winner Gets Prize owl <owl@rooftop.invalid> - 2019-03-22 19:59 +0000
Re: Programming Challenge - Winner Gets Prize "F. Russell" <frussell@random.info> - 2019-03-22 20:04 +0000
Re: Programming Challenge - Winner Gets Prize owl <owl@rooftop.invalid> - 2019-03-22 20:46 +0000
Re: Programming Challenge - Winner Gets Prize owl <owl@rooftop.invalid> - 2019-03-23 00:51 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] "F. Russell" <fr@random.info> - 2019-03-23 21:00 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] owl <owl@rooftop.invalid> - 2019-03-23 22:58 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] "F. Russell" <fr@random.info> - 2019-03-23 23:20 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] Steve Carroll <frelwizzen@gmail.com> - 2019-03-23 16:33 -0700
Re: Programming Challenge - Winner Gets Prize [SOLVED] owl <owl@rooftop.invalid> - 2019-03-23 23:34 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] "F. Russell" <fr@random.info> - 2019-03-23 23:44 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] owl <owl@rooftop.invalid> - 2019-03-24 00:59 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] owl <owl@rooftop.invalid> - 2019-03-24 03:49 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] Steve Carroll <frelwizzen@gmail.com> - 2019-03-23 21:16 -0700
Re: Programming Challenge - Winner Gets Prize [SOLVED] "F. Russell" <fr@random.info> - 2019-03-24 12:41 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] owl <owl@rooftop.invalid> - 2019-03-24 13:55 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] "F. Russell" <fr@random.info> - 2019-03-24 14:30 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] owl <owl@rooftop.invalid> - 2019-03-24 14:49 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] Steve Carroll <frelwizzen@gmail.com> - 2019-03-24 08:15 -0700
Re: Programming Challenge - Winner Gets Prize [SOLVED] "F. Russell" <fr@random.info> - 2019-03-24 15:31 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] Steve Carroll <fretwizzer@gmail.com> - 2019-03-24 08:48 -0700
Re: Programming Challenge - Winner Gets Prize [SOLVED] "F. Russell" <fr@random.info> - 2019-03-24 16:00 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] Steve Carroll <fretwizzer@gmail.com> - 2019-04-01 07:09 -0700
Re: Programming Challenge - Winner Gets Prize [SOLVED] Steven Petruzzellis <frelwizzen@gmail.com> - 2019-04-01 08:40 -0700
Re: Programming Challenge - Winner Gets Prize [SOLVED] Snit <usenet@gallopinginsanity.com> - 2019-03-24 17:23 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] owl <owl@rooftop.invalid> - 2019-03-24 17:25 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] owl <owl@rooftop.invalid> - 2019-03-24 18:48 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] "F. Russell" <fr@random.info> - 2019-03-24 19:27 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] owl <owl@rooftop.invalid> - 2019-03-24 23:03 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] Steve Carroll <frelwizzen@gmail.com> - 2019-03-24 16:33 -0700
Re: Programming Challenge - Winner Gets Prize [SOLVED] "F. Russell" <fr@random.info> - 2019-03-24 23:35 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] owl <owl@rooftop.invalid> - 2019-03-25 00:18 +0000
In my hands, vim is a worthless piece of shit. Jeff-Relf.Me @. - 2019-03-24 18:01 -0700
Re: In my hands, vim is a worthless piece of shit. Steve Carroll <frelwizzen@gmail.com> - 2019-03-24 18:21 -0700
Re: Programming Challenge - Winner Gets Prize [SOLVED] Steve Carroll <frelwizzen@gmail.com> - 2019-03-24 19:24 -0700
Re: Programming Challenge - Winner Gets Prize [SOLVED] Melzzzzz <Melzzzzz@zzzzz.com> - 2019-03-25 02:40 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] owl <owl@rooftop.invalid> - 2019-03-25 03:02 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] "F. Russell" <fr@random.info> - 2019-03-25 10:15 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] Steve Carroll <"Steve Carroll"@noSPAM.none> - 2019-03-25 14:56 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] "F. Russell" <fr@random.info> - 2019-03-25 09:30 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] Mel <mel@zzzzz.com> - 2019-03-25 10:42 +0100
Re: Programming Challenge - Winner Gets Prize [SOLVED] Melzzzzz <Melzzzzz@zzzzz.com> - 2019-03-25 02:39 +0000
Re: Programming Challenge - Winner Gets Prize [SOLVED] Steve Carroll <frelwizzen@gmail.com> - 2019-03-24 13:11 -0700
Re: Programming Challenge - Winner Gets Prize [SOLVED] Steve Carroll <frelwizzen@gmail.com> - 2019-03-24 14:29 -0700
Re: Programming Challenge - Winner Gets Prize [SOLVED] Steve Carroll <frelwizzen@gmail.com> - 2019-03-24 08:00 -0700
Re: Programming Challenge - Winner Gets Prize [SOLVED] Steve Carroll <frelwizzen@gmail.com> - 2019-03-24 07:11 -0700
Re: Programming Challenge - Winner Gets Prize Melzzzzz <Melzzzzz@zzzzz.com> - 2019-03-23 22:29 +0000
Re: Programming Challenge - Winner Gets Prize Steve Carroll <frelwizzen@gmail.com> - 2019-03-23 16:48 -0700
Re: Programming Challenge - Winner Gets Prize Steve Carroll <frelwizzen@gmail.com> - 2019-03-23 18:53 -0700
Re: Programming Challenge - Winner Gets Prize Steve Carroll <frelwizzen@gmail.com> - 2019-03-24 05:07 -0700
Re: Programming Challenge - Winner Gets Prize "F. Russell" <fr@random.info> - 2019-03-23 15:31 +0000
Re: Programming Challenge - Winner Gets Prize Steve Carroll <fretwizzer@gmail.com> - 2019-03-23 09:30 -0700
Re: Programming Challenge - Winner Gets Prize "F. Russell" <fr@random.info> - 2019-03-23 18:49 +0000
Re: Programming Challenge - Winner Gets Prize Nobody you know <nobody@nowhere.com> - 2019-03-23 20:25 -0400
Page 1 of 4 [1] 2 3 4 Next page →
| From | "F. Russell" <frussell@random.info> |
|---|---|
| Date | 2019-03-22 17:38 +0000 |
| Subject | Programming Challenge - Winner Gets Prize |
| Message-ID | <q736iu01av4@news3.newsguy.com> |
Programming Challenge -- using GNU/Linux tools only Computer algebra packages such as Maxima output equations like this: ... x^2 ... sin(x)^5 ... f(x)^10 ... But these equations cannot be pasted into a C source file because C uses the pow() function rather than "^." Also, in a C program pow() is inaccurate and slow and it would be better to convert, for example, "x^3" to "x*x*x." How can an expression like "x^3" or "f(x)^2" be converted to "x*x*x" and "f(x)*f(x)" ? In other words, given some text containing "expression^N" convert this to "expression*expression*expression*..." Also give a cutoff value so that if N>cutoff then the pow() function would be used. E.g. if cutoff=5, then "expression^6" would convert to pow(expression, 6).
[toc] | [next] | [standalone]
| From | Steve Carroll <fretwizzer@gmail.com> |
|---|---|
| Date | 2019-03-22 10:47 -0700 |
| Message-ID | <aa382000-f855-4513-a491-dbd01f0907cd@googlegroups.com> |
| In reply to | #489471 |
On Friday, March 22, 2019 at 11:38:47 AM UTC-6, F. Russell wrote: > Programming Challenge -- using GNU/Linux tools only > > Computer algebra packages such as Maxima output equations like this: > > ... x^2 ... sin(x)^5 ... f(x)^10 ... > > But these equations cannot be pasted into a C source file because C > uses the pow() function rather than "^." Also, in a C program pow() > is inaccurate and slow and it would be better to convert, for example, > "x^3" to "x*x*x." > > How can an expression like "x^3" or "f(x)^2" be converted to "x*x*x" > and "f(x)*f(x)" ? > > In other words, given some text containing "expression^N" convert this > to "expression*expression*expression*..." > > Also give a cutoff value so that if N>cutoff then the pow() function > would be used. E.g. if cutoff=5, then "expression^6" would convert > to pow(expression, 6). I'm terrible at math but can't you just write a function to call recursively with a parameter equal to the power? And why "GNU/Linux tools only"? Afraid DFS might show you up ;)
[toc] | [prev] | [next] | [standalone]
| From | "F. Russell" <frussell@random.info> |
|---|---|
| Date | 2019-03-22 17:56 +0000 |
| Message-ID | <q737kv01o5g@news4.newsguy.com> |
| In reply to | #489473 |
On Fri, 22 Mar 2019 10:47:01 -0700, Steve Carroll vomited this verbiage that I considered to be worthy of my attention for one of a variety of possible reasons: > > but can't you just write a function to call > recursively with a parameter equal to the power? > I though that I explained. The idea is to produce a C source file which can be compiled. But cutting and pasting a string containing "^" won't compile. Therefore, the string has to be converted to eliminate the "^." > > And why "GNU/Linux > tools only"? > GNU/Linux is the absolute best. That's why.
[toc] | [prev] | [next] | [standalone]
| From | "F. Russell" <frussell@random.info> |
|---|---|
| Date | 2019-03-22 18:07 +0000 |
| Message-ID | <q7389s01olu@news4.newsguy.com> |
| In reply to | #489477 |
On Fri, 22 Mar 2019 17:56:47 +0000, F. Russell vomited this verbiage that I considered to be worthy of my attention for one of a variety of possible reasons: > > The idea is to produce a C source file which can be compiled. > But cutting and pasting a string containing "^" won't compile. > Therefore, the string has to be converted to eliminate the "^." > Ideally, of course, this would take place in a text editor. The user would select the string and then invoke some accessory code to do the conversion "in place."
[toc] | [prev] | [next] | [standalone]
| From | Steve Carroll <fretwizzer@gmail.com> |
|---|---|
| Date | 2019-03-22 12:11 -0600 |
| Message-ID | <q738gg$4mg$1@dont-email.me> |
| In reply to | #489477 |
On 2019-03-22 17:56:47 +0000, F. Russell said: > On Fri, 22 Mar 2019 10:47:01 -0700, Steve Carroll vomited this verbiage > that I considered to be worthy of my attention for one of a variety of > possible reasons: > >> >> but can't you just write a function to call >> recursively with a parameter equal to the power? >> > > I though that I explained. > > The idea is to produce a C source file which can be compiled. > But cutting and pasting a string containing "^" won't compile. > Therefore, the string has to be converted to eliminate the "^." I assumed you just use regex for that part. That's the only thing I'd know to do <shrug>. > >> >> And why "GNU/Linux >> tools only"? >> > > GNU/Linux is the absolute best. That's why.
[toc] | [prev] | [next] | [standalone]
| From | Melzzzzz <Melzzzzz@zzzzz.com> |
|---|---|
| Date | 2019-03-22 19:29 +0000 |
| Message-ID | <LIalE.190472$kh.60455@fx27.am4> |
| In reply to | #489473 |
On 2019-03-22, Steve Carroll <fretwizzer@gmail.com> wrote: > On Friday, March 22, 2019 at 11:38:47 AM UTC-6, F. Russell wrote: >> Programming Challenge -- using GNU/Linux tools only >> >> Computer algebra packages such as Maxima output equations like this: >> >> ... x^2 ... sin(x)^5 ... f(x)^10 ... >> >> But these equations cannot be pasted into a C source file because C >> uses the pow() function rather than "^." Also, in a C program pow() >> is inaccurate and slow and it would be better to convert, for example, >> "x^3" to "x*x*x." >> >> How can an expression like "x^3" or "f(x)^2" be converted to "x*x*x" >> and "f(x)*f(x)" ? >> >> In other words, given some text containing "expression^N" convert this >> to "expression*expression*expression*..." >> >> Also give a cutoff value so that if N>cutoff then the pow() function >> would be used. E.g. if cutoff=5, then "expression^6" would convert >> to pow(expression, 6). > > I'm terrible at math but can't you just write a function to call recursively > with a parameter equal to the power? And why "GNU/Linux tools only"? Not efficent.... > Afraid DFS might show you up ;) -- press any key to continue or any other to quit...
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2019-03-22 19:48 +0000 |
| Message-ID | <sz8xb803.ay4@rooftop.invalid> |
| In reply to | #489471 |
F. Russell <frussell@random.info> wrote: > Programming Challenge -- using GNU/Linux tools only > > Computer algebra packages such as Maxima output equations like this: > > ... x^2 ... sin(x)^5 ... f(x)^10 ... > > But these equations cannot be pasted into a C source file because C > uses the pow() function rather than "^." Also, in a C program pow() > is inaccurate and slow and it would be better to convert, for example, > "x^3" to "x*x*x." > > How can an expression like "x^3" or "f(x)^2" be converted to "x*x*x" > and "f(x)*f(x)" ? > > In other words, given some text containing "expression^N" convert this > to "expression*expression*expression*..." > > Also give a cutoff value so that if N>cutoff then the pow() function > would be used. E.g. if cutoff=5, then "expression^6" would convert > to pow(expression, 6). > Trivial in vim. https://streamable.com/qepcs
[toc] | [prev] | [next] | [standalone]
| From | Melzzzzz <Melzzzzz@zzzzz.com> |
|---|---|
| Date | 2019-03-22 19:51 +0000 |
| Message-ID | <P0blE.390279$M53.349215@fx31.am4> |
| In reply to | #489513 |
On 2019-03-22, owl <owl@rooftop.invalid> wrote: > F. Russell <frussell@random.info> wrote: >> Programming Challenge -- using GNU/Linux tools only >> >> Computer algebra packages such as Maxima output equations like this: >> >> ... x^2 ... sin(x)^5 ... f(x)^10 ... >> >> But these equations cannot be pasted into a C source file because C >> uses the pow() function rather than "^." Also, in a C program pow() >> is inaccurate and slow and it would be better to convert, for example, >> "x^3" to "x*x*x." >> >> How can an expression like "x^3" or "f(x)^2" be converted to "x*x*x" >> and "f(x)*f(x)" ? >> >> In other words, given some text containing "expression^N" convert this >> to "expression*expression*expression*..." >> >> Also give a cutoff value so that if N>cutoff then the pow() function >> would be used. E.g. if cutoff=5, then "expression^6" would convert >> to pow(expression, 6). >> > > Trivial in vim. > https://streamable.com/qepcs It's not in vim... > -- press any key to continue or any other to quit...
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2019-03-22 19:54 +0000 |
| Message-ID | <szx8c083g.ay@rooftop.invalid> |
| In reply to | #489514 |
Melzzzzz <Melzzzzz@zzzzz.com> wrote: > On 2019-03-22, owl <owl@rooftop.invalid> wrote: >> F. Russell <frussell@random.info> wrote: >>> Programming Challenge -- using GNU/Linux tools only >>> >>> Computer algebra packages such as Maxima output equations like this: >>> >>> ... x^2 ... sin(x)^5 ... f(x)^10 ... >>> >>> But these equations cannot be pasted into a C source file because C >>> uses the pow() function rather than "^." Also, in a C program pow() >>> is inaccurate and slow and it would be better to convert, for example, >>> "x^3" to "x*x*x." >>> >>> How can an expression like "x^3" or "f(x)^2" be converted to "x*x*x" >>> and "f(x)*f(x)" ? >>> >>> In other words, given some text containing "expression^N" convert this >>> to "expression*expression*expression*..." >>> >>> Also give a cutoff value so that if N>cutoff then the pow() function >>> would be used. E.g. if cutoff=5, then "expression^6" would convert >>> to pow(expression, 6). >>> >> >> Trivial in vim. >> https://streamable.com/qepcs > > It's not in vim... >> Sure it is. It's right there in my .vimrc :) :vnoremap <F7> :!./fab<CR>
[toc] | [prev] | [next] | [standalone]
| From | Melzzzzz <Melzzzzz@zzzzz.com> |
|---|---|
| Date | 2019-03-22 19:56 +0000 |
| Message-ID | <c6blE.266151$aO1.225328@fx14.am4> |
| In reply to | #489515 |
On 2019-03-22, owl <owl@rooftop.invalid> wrote: > Melzzzzz <Melzzzzz@zzzzz.com> wrote: >> On 2019-03-22, owl <owl@rooftop.invalid> wrote: >>> F. Russell <frussell@random.info> wrote: >>>> Programming Challenge -- using GNU/Linux tools only >>>> >>>> Computer algebra packages such as Maxima output equations like this: >>>> >>>> ... x^2 ... sin(x)^5 ... f(x)^10 ... >>>> >>>> But these equations cannot be pasted into a C source file because C >>>> uses the pow() function rather than "^." Also, in a C program pow() >>>> is inaccurate and slow and it would be better to convert, for example, >>>> "x^3" to "x*x*x." >>>> >>>> How can an expression like "x^3" or "f(x)^2" be converted to "x*x*x" >>>> and "f(x)*f(x)" ? >>>> >>>> In other words, given some text containing "expression^N" convert this >>>> to "expression*expression*expression*..." >>>> >>>> Also give a cutoff value so that if N>cutoff then the pow() function >>>> would be used. E.g. if cutoff=5, then "expression^6" would convert >>>> to pow(expression, 6). >>>> >>> >>> Trivial in vim. >>> https://streamable.com/qepcs >> >> It's not in vim... >>> > > Sure it is. It's right there in my .vimrc :) >:vnoremap <F7> :!./fab<CR> What's fab? > > -- press any key to continue or any other to quit...
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2019-03-22 19:59 +0000 |
| Message-ID | <szb080a3ta.h34@rooftop.invalid> |
| In reply to | #489516 |
Melzzzzz <Melzzzzz@zzzzz.com> wrote:
> On 2019-03-22, owl <owl@rooftop.invalid> wrote:
>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>> On 2019-03-22, owl <owl@rooftop.invalid> wrote:
>>>> F. Russell <frussell@random.info> wrote:
>>>>> Programming Challenge -- using GNU/Linux tools only
>>>>>
>>>>> Computer algebra packages such as Maxima output equations like this:
>>>>>
>>>>> ... x^2 ... sin(x)^5 ... f(x)^10 ...
>>>>>
>>>>> But these equations cannot be pasted into a C source file because C
>>>>> uses the pow() function rather than "^." Also, in a C program pow()
>>>>> is inaccurate and slow and it would be better to convert, for example,
>>>>> "x^3" to "x*x*x."
>>>>>
>>>>> How can an expression like "x^3" or "f(x)^2" be converted to "x*x*x"
>>>>> and "f(x)*f(x)" ?
>>>>>
>>>>> In other words, given some text containing "expression^N" convert this
>>>>> to "expression*expression*expression*..."
>>>>>
>>>>> Also give a cutoff value so that if N>cutoff then the pow() function
>>>>> would be used. E.g. if cutoff=5, then "expression^6" would convert
>>>>> to pow(expression, 6).
>>>>>
>>>>
>>>> Trivial in vim.
>>>> https://streamable.com/qepcs
>>>
>>> It's not in vim...
>>>>
>>
>> Sure it is. It's right there in my .vimrc :)
>>:vnoremap <F7> :!./fab<CR>
>
> What's fab?
>>
Oh, you mean that...
#!/bin/bash
while read x;do
stuff=$(echo ${x} |sed -e 's/\(.*\)\^.*/\1/g')
count=$(echo ${x} |sed -e 's/.*\^\(.*\)/\1/g')
if [ "${count}" -lt 7 ];then
for (( i = 1; i <= ${count} ; i++)); do
echo -n "${stuff}"
if [ "${i}" -lt "${count}" ]; then
echo -n "*"
fi
done
else
echo "pow(${stuff},${count})"
fi
echo
done
anon@lowtide:~/code/vim/work$
[toc] | [prev] | [next] | [standalone]
| From | "F. Russell" <frussell@random.info> |
|---|---|
| Date | 2019-03-22 20:04 +0000 |
| Message-ID | <q73f4c01v4d@news2.newsguy.com> |
| In reply to | #489513 |
On Fri, 22 Mar 2019 19:48:34 +0000, owl vomited this verbiage that I considered to be worthy of my attention for one of a variety of possible reasons: > > Trivial in vim. > What happens with this string? (Turn off any text wrapping.) (2*g*l^2*m^2*cos(y3)^2*sin(y3)^2)/(l*(m+M)-l*m*cos(y3)^2)^2+(-2*l^3*m^2*y1^2*cos(y3)*sin(y3)^2)/(l*(m+M)-l*m*cos(y3)^2)^2+(-g*l*m*cos(y3)^2)/(l*(m+M)-l*m*cos(y3)^2)+(l^2*m*y1^2*cos(y3))/(l*(m+M)-l*m*cos(y3)^2)
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2019-03-22 20:46 +0000 |
| Message-ID | <szb8080bz.3@rooftop.invalid> |
| In reply to | #489519 |
F. Russell <frussell@random.info> wrote: > On Fri, 22 Mar 2019 19:48:34 +0000, owl vomited this verbiage that I > considered to be worthy of my attention for one of a variety of possible > reasons: > >> >> Trivial in vim. >> > > > What happens with this string? (Turn off any text wrapping.) > > (2*g*l^2*m^2*cos(y3)^2*sin(y3)^2)/(l*(m+M)-l*m*cos(y3)^2)^2+(-2*l^3*m^2*y1^2*cos(y3)*sin(y3)^2)/(l*(m+M)-l*m*cos(y3)^2)^2+(-g*l*m*cos(y3)^2)/(l*(m+M)-l*m*cos(y3)^2)+(l^2*m*y1^2*cos(y3))/(l*(m+M)-l*m*cos(y3)^2) > Looks like you need to break out flex, or else massage your input. I've got to head out now. Might give it a look-see later.
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2019-03-23 00:51 +0000 |
| Message-ID | <sxzb80.buzo3@rooftop.invalid> |
| In reply to | #489535 |
owl <owl@rooftop.invalid> wrote: > F. Russell <frussell@random.info> wrote: >> On Fri, 22 Mar 2019 19:48:34 +0000, owl vomited this verbiage that I >> considered to be worthy of my attention for one of a variety of possible >> reasons: >> >>> >>> Trivial in vim. >>> >> >> >> What happens with this string? (Turn off any text wrapping.) >> >> (2*g*l^2*m^2*cos(y3)^2*sin(y3)^2)/(l*(m+M)-l*m*cos(y3)^2)^2+(-2*l^3*m^2*y1^2*cos(y3)*sin(y3)^2)/(l*(m+M)-l*m*cos(y3)^2)^2+(-g*l*m*cos(y3)^2)/(l*(m+M)-l*m*cos(y3)^2)+(l^2*m*y1^2*cos(y3))/(l*(m+M)-l*m*cos(y3)^2) >> > > Looks like you need to break out flex, or else massage your input. > I've got to head out now. Might give it a look-see later. > OK, the easiest way I see to do it is this: Put these two lines in your .vimrc: :nnoremap <F6> :/\^<CR> :nnoremap <F7> :.!./fab<CR> fab is the shell script from before and should be in the same directory as the file. Put your file in this format (isolate the exponent sections and show line numbers): 1 (2*g* 2 l^2 3 * 4 m^2 5 * 6 cos(y3)^2 7 * 8 sin(y3)^2 9 )/ 10 (l*(m+M)-l*m*cos(y3)^2)^2 11 +(-2* 12 l^3 13 * 14 m^2 15 * 16 y1^2 17 *cos(y3)* 18 sin(y3)^2 19 )/ 20 (l*(m+M)-l*m*cos(y3)^2)^2 21 +(-g*l*m* 22 cos(y3)^2 23 )/(l*(m+M)-l*m* 24 cos(y3)^2 25 )+( 26 l^2 27 *m* 28 y1^2 29 *cos(y3))/(l*(m+M)-l*m* 30 cos(y3)^2 31 ) F6 will jump to the next line containing a '^'. F7 will run the script and convert that line. Note that there is are two nested exponents (on lines 10 and 24). Work those first with F7 to get rid of the nesting. After that it's just a matter of hitting F6 and F7 until all the exponents are taken care of. Then join the lines and strip out the spaces and you're done. Probably takes about 5 minutes altogether. https://streamable.com/fn3ir
[toc] | [prev] | [next] | [standalone]
| From | "F. Russell" <fr@random.info> |
|---|---|
| Date | 2019-03-23 21:00 +0000 |
| Subject | Re: Programming Challenge - Winner Gets Prize [SOLVED] |
| Message-ID | <q766ps0n5o@news1.newsguy.com> |
| In reply to | #489583 |
On Sat, 23 Mar 2019 00:51:18 +0000, owl wrote:
>
> OK, the easiest way I see to do it is this:
>
Shoot! Sometimes I just can't see the trees for the forest.
Instead of focusing on the entire expression it would be far easier
to just select the portions with the exponent and operate on those.
In cooledit, the absolute best text editor for GNU/Linux, just
make a selection and then invoke the following built-in script with
either the menu or a hot key:
#!/bin/sh
slct=`cat %b`
cutoff=5
mtp=${slct%^*}
pw=${slct#*^}
if [ "$pw" -lt "$cutoff" ]
then
while [ $pw -gt "1" ]
do
echo -n $mtp"*" 2>%e
pw=$(($pw-1))
done
echo -n $mtp 2>%e
else
echo -n "pow($mtp,$pw)" 2>%e
fi
In cooledit, %b represents the selected block and %e is STDOUT.
In this way, the STDOUT is written to replace the selected text.
Also, there is no modification of config files. The scripts
are created through a dialog within the program.
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2019-03-23 22:58 +0000 |
| Subject | Re: Programming Challenge - Winner Gets Prize [SOLVED] |
| Message-ID | <xz80aga03.tyho34@rooftop.invalid> |
| In reply to | #489671 |
F. Russell <fr@random.info> wrote:
> On Sat, 23 Mar 2019 00:51:18 +0000, owl wrote:
>
>>
>> OK, the easiest way I see to do it is this:
>>
>
> Shoot! Sometimes I just can't see the trees for the forest.
>
> Instead of focusing on the entire expression it would be far easier
> to just select the portions with the exponent and operate on those.
>
> In cooledit, the absolute best text editor for GNU/Linux, just
> make a selection and then invoke the following built-in script with
> either the menu or a hot key:
>
> #!/bin/sh
>
> slct=`cat %b`
> cutoff=5
>
> mtp=${slct%^*}
> pw=${slct#*^}
>
> if [ "$pw" -lt "$cutoff" ]
> then
> while [ $pw -gt "1" ]
> do
> echo -n $mtp"*" 2>%e
> pw=$(($pw-1))
> done
> echo -n $mtp 2>%e
> else
> echo -n "pow($mtp,$pw)" 2>%e
> fi
>
> In cooledit, %b represents the selected block and %e is STDOUT.
> In this way, the STDOUT is written to replace the selected text.
>
> Also, there is no modification of config files. The scripts
> are created through a dialog within the program.
>
I see an option to insert stdout from a script, but not to overwrite
the selected text. What are you doing with stdout? You realize that
if you're selecting text with the mouse, any script can process $(xsel -o)
and present the output to you in a tiny xterm window. You don't even
need to have the text in an editor for that.
[toc] | [prev] | [next] | [standalone]
| From | "F. Russell" <fr@random.info> |
|---|---|
| Date | 2019-03-23 23:20 +0000 |
| Subject | Re: Programming Challenge - Winner Gets Prize [SOLVED] |
| Message-ID | <q76evr0qap@news4.newsguy.com> |
| In reply to | #489675 |
On Sat, 23 Mar 2019 22:58:18 +0000, owl wrote: > > I see an option to insert stdout from a script, but not to overwrite > the selected text. What are you doing with stdout? > Cooledit has an option to write the output of an internal script as a replacement for text that is selected. That's what is happening here. It works. Install cooledit and you will find a menu entry called Scripts-->New Scripts. Just enter the bash (or perl, etc.) code in the dialog pane and select the option to replace the selected text with stdout or stderr. The scripts can also be created/edited in the .cooledit.ini config file. > > You realize that > if you're selecting text with the mouse, any script can process $(xsel -o) > and present the output to you in a tiny xterm window. You don't even > need to have the text in an editor for that. > I'm not sure what you are saying here. I am copying and pasting text from wxmaxima to cooledit. These pastes have the incompatible "^" operator and need to be converted. Within cooledit, I select text, hit a hot key, and the text is converted. Furthermore, I can define the cutoff value as an option to be entered in a dialog prompt. Can vim do that? I thought not.
[toc] | [prev] | [next] | [standalone]
| From | Steve Carroll <frelwizzen@gmail.com> |
|---|---|
| Date | 2019-03-23 16:33 -0700 |
| Subject | Re: Programming Challenge - Winner Gets Prize [SOLVED] |
| Message-ID | <6c861112-c058-480b-8cf5-8426d125ff79@googlegroups.com> |
| In reply to | #489680 |
On Saturday, March 23, 2019 at 4:20:54 PM UTC-7, F. Russell wrote: > On Sat, 23 Mar 2019 22:58:18 +0000, owl wrote: > > > > > I see an option to insert stdout from a script, but not to overwrite > > the selected text. What are you doing with stdout? > > > > Cooledit has an option to write the output of an internal script as > a replacement for text that is selected. That's what is happening here. > It works. > > Install cooledit and you will find a menu entry called Scripts-->New Scripts. > Just enter the bash (or perl, etc.) code in the dialog pane and select the > option to replace the selected text with stdout or stderr. > > The scripts can also be created/edited in the .cooledit.ini config > file. > > > > > You realize that > > if you're selecting text with the mouse, any script can process $(xsel -o) > > and present the output to you in a tiny xterm window. You don't even > > need to have the text in an editor for that. > > > > I'm not sure what you are saying here. > > I am copying and pasting text from wxmaxima to cooledit. These pastes > have the incompatible "^" operator and need to be converted. > > Within cooledit, I select text, hit a hot key, and the text is converted. > > Furthermore, I can define the cutoff value as an option to be entered > in a dialog prompt. Can vim do that? I thought not. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hi, Snit! -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJYY/GZAAoJELnOYK54exUCoY8P/A2to3G0OJrV4rFZqrfos0G+ Hlz52idYDsiO9KbYI9E2AaEhX5Jado6kJgDD31LTOnYSHrIuTi/LeywcjOL/FCy7 bEojPW3xtu/XWHHSKU1Grce80Q2PHuR+878JDbCjXgrFplNEVk8+kiv2+5RlYegG 7xEgm+/J8zvxVlPfyoHOO65AygYy/ykShdza+MAW6OFWaXFNOxExjRx3mCmWcu3b eyf0bxgzL4zAFCuPBAOXQ56vxO8AOuwk8F7mXLV2Vn2Q2OTcqrEYMjwQZ2q7wFSg khU6VkEs7aFJ6keLSCoZlFmnoymptflJw3h0O6bb9GK67JBV6Moh5rev6aJfqGuZ fo38FgD/eRVroAYSm3FSCcknNbUhdNLUO/JmCRtx62YQvZoyUqUL64YRGlJ+moAV ZnU6NfI4WeeQ5nuagTS+kKjj1qGxsUkXEUTFRJpv4zQcHnTKTyUl+38t3+Jke7ua NRtkWtIvgg9+JCsA1qHjDDP29hdR5v7KFFnRKBaVgV+/nrALANWybFJKYsqxpP95 LMd0pxvEy2ZlX9n3nkmMIn4iRX3dY795NgOzHGd1ZWtMS3BPu4QWFA/YS7Adb30Z yHClb/JJWGtTPvgVtPzHyNbPhF6+kgJ/KQ6YrqiX71ZNLZNqCze7z3nw6xjcWr9V soXbWlBBa6AX7lnolpK8 =hcV2 -----END PGP SIGNATURE----- -- Get Rich Slow!! http://www.5z8.info/gruesome-gunshot-wounds_t5z0au_cockdock.gif https://www.facebook.com/jenny.eklund https://youtu.be/E3m_i-x92D0 Jonas Eklundh Communication AB
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2019-03-23 23:34 +0000 |
| Subject | Re: Programming Challenge - Winner Gets Prize [SOLVED] |
| Message-ID | <sz0b8934g.a@rooftop.invalid> |
| In reply to | #489680 |
F. Russell <fr@random.info> wrote: > On Sat, 23 Mar 2019 22:58:18 +0000, owl wrote: > >> >> I see an option to insert stdout from a script, but not to overwrite >> the selected text. What are you doing with stdout? >> > > Cooledit has an option to write the output of an internal script as > a replacement for text that is selected. That's what is happening here. > It works. > > Install cooledit and you will find a menu entry called Scripts-->New Scripts. > Just enter the bash (or perl, etc.) code in the dialog pane and select the > option to replace the selected text with stdout or stderr. > I don't see that option. https://imgur.com/a/JDyaZif > The scripts can also be created/edited in the .cooledit.ini config > file. > >> >> You realize that >> if you're selecting text with the mouse, any script can process $(xsel -o) >> and present the output to you in a tiny xterm window. You don't even >> need to have the text in an editor for that. >> > > I'm not sure what you are saying here. > Select some text anywhere and run xsel -o in a terminal. That output can be fed to a script. > I am copying and pasting text from wxmaxima to cooledit. These pastes > have the incompatible "^" operator and need to be converted. > > Within cooledit, I select text, hit a hot key, and the text is converted. > > Furthermore, I can define the cutoff value as an option to be entered > in a dialog prompt. Can vim do that? I thought not. > Your script is defining the cutoff. Of course "vim can do that", because vim can work with any script or pipeline of scripts. And there is no need to enter them into some internal dialog. With vim you just call the script with its path using :!
[toc] | [prev] | [next] | [standalone]
| From | "F. Russell" <fr@random.info> |
|---|---|
| Date | 2019-03-23 23:44 +0000 |
| Subject | Re: Programming Challenge - Winner Gets Prize [SOLVED] |
| Message-ID | <q76gca06e7@news2.newsguy.com> |
| In reply to | #489682 |
On Sat, 23 Mar 2019 23:34:39 +0000, owl wrote: > > I don't see that option. > Actually the option is called "Insert stdout on completion." The cooledit documentation does not have much info on scripting but it says to examine the other built-in scripts for guidance. So look at the other scripts and you will see what is happening. > > Select some text anywhere and run xsel -o in a terminal. That output > can be fed to a script. > OK. But that does not have any relevance here. > > Your script is defining the cutoff. Of course "vim can do that", because > vim can work with any script or pipeline of scripts. And there is no need > to enter them into some internal dialog. With vim you just call the script > with its path using :! > But my script does not have to define the cutoff value. I may decide that I want a different cutoff for different places. Thus I could dynamically assign the cutoff value, with a dialog prompt, before each and every replacement. Can vim assign script values dynamically by prompting the user? I thought not.
[toc] | [prev] | [next] | [standalone]
Page 1 of 4 [1] 2 3 4 Next page →
Back to top | Article view | comp.os.linux.advocacy
csiph-web