Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.advocacy > #465275 > unrolled thread
| Started by | DFS <nospam@nospam.com> |
|---|---|
| First post | 2018-08-28 08:28 -0400 |
| Last post | 2018-08-29 15:12 +0000 |
| Articles | 17 on this page of 57 — 6 participants |
Back to article view | Back to comp.os.linux.advocacy
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-28 08:28 -0400
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 09:20 -0700
Re: The substantiation that -highhorse asked for fr314159@gmail.com - 2018-08-28 11:27 -0700
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 11:39 -0700
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-29 09:46 -0400
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-28 14:52 -0400
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 12:20 -0700
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 17:21 +0000
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-28 14:46 -0400
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 19:14 +0000
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 12:30 -0700
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 20:09 +0000
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 13:58 -0700
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 21:16 +0000
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 14:31 -0700
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 21:43 +0000
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 15:06 -0700
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 22:26 +0000
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-28 15:35 -0700
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-28 23:14 +0000
Re: The substantiation that -highhorse asked for Snit <usenet@gallopinginsanity.com> - 2018-08-28 14:57 -0700
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-28 23:11 -0400
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-29 06:14 +0000
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-29 09:34 -0400
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-29 14:31 +0000
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-29 11:01 -0700
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-31 12:33 +0000
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-31 09:16 -0700
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-31 16:53 +0000
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-31 10:22 -0700
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-31 17:53 +0000
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-08-31 11:36 -0700
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 13:45 +0000
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 13:59 +0000
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-09-01 08:15 -0700
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 16:00 +0000
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-09-01 11:20 -0700
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-31 15:00 -0400
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-31 19:40 +0000
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-09-01 10:15 -0400
Re: The substantiation that -highhorse asked for Steve Carroll <fretwizzer@gmail.com> - 2018-09-01 08:22 -0700
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 16:28 +0000
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-09-01 16:39 -0400
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 22:00 +0000
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-09-01 18:27 -0400
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 22:40 +0000
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-09-01 19:09 -0400
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-09-01 23:59 +0000
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-28 23:01 -0400
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-29 06:26 +0000
Re: The substantiation that -highhorse asked for "F. Russell" <fr@random.info> - 2018-08-28 19:25 +0000
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-29 09:32 -0400
Re: The substantiation that -highhorse asked for fr314159@gmail.com - 2018-08-29 06:46 -0700
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-08-29 09:55 -0400
Re: The substantiation that -highhorse asked for fr314159@gmail.com - 2018-08-29 08:02 -0700
Re: The substantiation that -highhorse asked for DFS <nospam@nospam.com> - 2018-09-01 10:14 -0400
Re: The substantiation that -highhorse asked for owl <owl@rooftop.invalid> - 2018-08-29 15:12 +0000
Page 3 of 3 — ← Prev page 1 2 [3]
| From | Steve Carroll <fretwizzer@gmail.com> |
|---|---|
| Date | 2018-09-01 08:22 -0700 |
| Message-ID | <ed30ef85-e4da-43a0-99bc-86b93f98a91f@googlegroups.com> |
| In reply to | #465497 |
On Saturday, September 1, 2018 at 8:14:40 AM UTC-6, DFS wrote:
> On 8/31/2018 3:40 PM, owl wrote:
> > DFS <nospam@nospam.com> wrote:
> >> On 8/29/2018 10:31 AM, owl wrote:
> >>> DFS <nospam@nospam.com> wrote:
> >>>> On 8/29/2018 2:14 AM, owl wrote:
> >>>>> DFS <nospam@nospam.com> wrote:
> >>>
> >>>> affirmative
> >>
> >>
> >>> But who would write it that way, and why?
> >>
> >> Someone drunk at 2:14am, because they were drunk.
> >>
> >>
> >>> Sure, there's no if statements,
> >>> but that comes at the expense of 1,000,001 function pointers. And the
> >>> nested ternaries constitute conditional tests anyway. Not to mention
> >>> less readability. It would run faster, use less stack, and be much more
> >>> readable and faster to design and write without error, by just using a
> >>> list of ifs.
> >>
> >> Congrats on beating up your own strawman.
> >
> > How so? I showed that striving for some subjective code "elegance" by
> > reducing the number of visible ifs (your desire), when carried to the
> > extreme of zero, is detrimental to performance.
>
> 'when carried to the extreme'... strawman in the house!
>
>
> > Your code contains the
> > same number of conditional tests in the loop as would be run without
> > the loop, takes longer to code, is more prone to errors in construction,
> > is arguably less readable, is less flexible in condition actions, and
> > provides no performance benefit. But somehow that makes it more elegant
> > than a straight if/else sequence?
>
>
> Are you arguing just to argue? Or did Feeb promise favors?
>
> 'Cause his stupid hard-coded one if-then-else for each income bracket is
> silly. Each year he has to check if the code corresponds one-on-one to
> the number of income brackets.
Agreed... this makes no sense, even for a prototype that makes it off
the developer's computer.
> I'm reasonable; in the past this was my typical code for setting dates
> on an Access screen, after you choose from a list of date periods:
>
> Public Function getStartDate(period As String) As Date
> If period = "YTD" Then
> getStartDate = "01-Jan-" & DatePart("yyyy", Date)
> ElseIf period = "Today" Then getStartDate = Date
> ElseIf period = "Yesterday" Then getStartDate = Date - 1
> ElseIf period = "Last Week" Then getStartDate = Date - 6
> ElseIf period = "Last 2 Weeks" Then getStartDate = Date - 13
> ElseIf period = "Last Month" Then getStartDate = Date - 30
> ElseIf period = "Last 3 Months" Then getStartDate = Date - 90
> ElseIf period = "Last 6 Months" Then getStartDate = Date - 180
> ElseIf period = "Last Year" Then getStartDate = Date - 365
> ElseIf period = "Last 2 Years" Then getStartDate = Date - (365 * 2)
> ElseIf period = "Last 3 Years" Then getStartDate = Date - (365 * 3)
> ElseIf period = "Last 4 Years" Then getStartDate = Date - (365 * 4)
> ElseIf period = "Last 5 Years" Then getStartDate = Date - (365 * 5)
> ElseIf period = "Last 10 Years" Then getStartDate = Date - (365 * 10)
> ElseIf period = "Last 15 Years" Then getStartDate = Date - (365 * 15)
> End If
>
> End Function
>
>
> I could make a couple clunky for...loops, but in this case it's
> inappropriate.
And... as has been pointed out... this is probably easier to read than a
clunky loop; I'd argue that good (longer) naming helps the loop, though.
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2018-09-01 16:28 +0000 |
| Message-ID | <9b0z880b3.ago@rooftop.invalid> |
| In reply to | #465497 |
DFS <nospam@nospam.com> wrote:
> On 8/31/2018 3:40 PM, owl wrote:
>> DFS <nospam@nospam.com> wrote:
>>> On 8/29/2018 10:31 AM, owl wrote:
>>>> DFS <nospam@nospam.com> wrote:
>>>>> On 8/29/2018 2:14 AM, owl wrote:
>>>>>> DFS <nospam@nospam.com> wrote:
>>>>
>>>>> affirmative
>>>
>>>
>>>> But who would write it that way, and why?
>>>
>>> Someone drunk at 2:14am, because they were drunk.
>>>
>>>
>>>> Sure, there's no if statements,
>>>> but that comes at the expense of 1,000,001 function pointers. And the
>>>> nested ternaries constitute conditional tests anyway. Not to mention
>>>> less readability. It would run faster, use less stack, and be much more
>>>> readable and faster to design and write without error, by just using a
>>>> list of ifs.
>>>
>>> Congrats on beating up your own strawman.
>>
>> How so? I showed that striving for some subjective code "elegance" by
>> reducing the number of visible ifs (your desire), when carried to the
>> extreme of zero, is detrimental to performance.
>
> 'when carried to the extreme'... strawman in the house!
>
Carried to its natural conclusion.
>
>> Your code contains the
>> same number of conditional tests in the loop as would be run without
>> the loop, takes longer to code, is more prone to errors in construction,
>> is arguably less readable, is less flexible in condition actions, and
>> provides no performance benefit. But somehow that makes it more elegant
>> than a straight if/else sequence?
>
>
> Are you arguing just to argue?
Yes.
> Or did Feeb promise favors?
>
> 'Cause his stupid hard-coded one if-then-else for each income bracket is
> silly. Each year he has to check if the code corresponds one-on-one to
> the number of income brackets.
>
> I'm reasonable; in the past this was my typical code for setting dates
> on an Access screen, after you choose from a list of date periods:
>
> Public Function getStartDate(period As String) As Date
> If period = "YTD" Then
> getStartDate = "01-Jan-" & DatePart("yyyy", Date)
> ElseIf period = "Today" Then getStartDate = Date
> ElseIf period = "Yesterday" Then getStartDate = Date - 1
> ElseIf period = "Last Week" Then getStartDate = Date - 6
> ElseIf period = "Last 2 Weeks" Then getStartDate = Date - 13
> ElseIf period = "Last Month" Then getStartDate = Date - 30
> ElseIf period = "Last 3 Months" Then getStartDate = Date - 90
> ElseIf period = "Last 6 Months" Then getStartDate = Date - 180
> ElseIf period = "Last Year" Then getStartDate = Date - 365
> ElseIf period = "Last 2 Years" Then getStartDate = Date - (365 * 2)
> ElseIf period = "Last 3 Years" Then getStartDate = Date - (365 * 3)
> ElseIf period = "Last 4 Years" Then getStartDate = Date - (365 * 4)
> ElseIf period = "Last 5 Years" Then getStartDate = Date - (365 * 5)
> ElseIf period = "Last 10 Years" Then getStartDate = Date - (365 * 10)
> ElseIf period = "Last 15 Years" Then getStartDate = Date - (365 * 15)
> End If
>
> End Function
>
>
> I could make a couple clunky for...loops, but in this case it's
> inappropriate.
>
No ifs, ands, or buttloops...
#!/bin/bash
declare -A starts
if [ ${#} -ne 1 ];then
echo "feed me a date period"
exit
fi
datefmt="+%d-%b-%Y"
starts["YTD"]=$(date -d "Jan 1" ${datefmt})
starts["Today"]=$(date -d "today" ${datefmt})
starts["Yesterday"]=$(date -d "today -1 days" ${datefmt})
starts["Last Week"]=$(date -d "today -6 days" ${datefmt})
starts["Last 2 Weeks"]=$(date -d "today -13 days" ${datefmt})
starts["Last Month"]=$(date -d "today -30 days" ${datefmt})
starts["Last 3 Months"]=$(date -d "today -90 days" ${datefmt})
starts["Last 6 Months"]=$(date -d "today -180 days" ${datefmt})
starts["Last Year"]=$(date -d "today -1 year" ${datefmt})
starts["Last 2 Years"]=$(date -d "today - 2 years" ${datefmt})
starts["Last 3 Years"]=$(date -d "today - 3 years" ${datefmt})
starts["Last 4 Years"]=$(date -d "today - 4 years" ${datefmt})
starts["Last 5 Years"]=$(date -d "today - 5 years" ${datefmt})
starts["Last 10 Years"]=$(date -d "today - 10 years" ${datefmt})
starts["Last 15 Years"]=$(date -d "today - 15 years" ${datefmt})
echo ${starts["${1}"]}
anon@lowtide:~/code/ifs$
anon@lowtide:~/code/ifs$ ./startdate YTD
01-Jan-2018
anon@lowtide:~/code/ifs$ ./startdate "Last 15 Years"
01-Sep-2003
anon@lowtide:~/code/ifs$ ./startdate "Last Week"
26-Aug-2018
anon@lowtide:~/code/ifs$
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@nospam.com> |
|---|---|
| Date | 2018-09-01 16:39 -0400 |
| Message-ID | <pOCiD.19384$Vl2.16436@fx46.iad> |
| In reply to | #465503 |
On 9/1/2018 12:28 PM, owl wrote:
> No ifs, ands, or buttloops...
>
> #!/bin/bash
> declare -A starts
> if [ ${#} -ne 1 ];then
> echo "feed me a date period"
> exit
> fi
> datefmt="+%d-%b-%Y"
> starts["YTD"]=$(date -d "Jan 1" ${datefmt})
> starts["Today"]=$(date -d "today" ${datefmt})
> starts["Yesterday"]=$(date -d "today -1 days" ${datefmt})
> starts["Last Week"]=$(date -d "today -6 days" ${datefmt})
> starts["Last 2 Weeks"]=$(date -d "today -13 days" ${datefmt})
> starts["Last Month"]=$(date -d "today -30 days" ${datefmt})
> starts["Last 3 Months"]=$(date -d "today -90 days" ${datefmt})
> starts["Last 6 Months"]=$(date -d "today -180 days" ${datefmt})
> starts["Last Year"]=$(date -d "today -1 year" ${datefmt})
> starts["Last 2 Years"]=$(date -d "today - 2 years" ${datefmt})
> starts["Last 3 Years"]=$(date -d "today - 3 years" ${datefmt})
> starts["Last 4 Years"]=$(date -d "today - 4 years" ${datefmt})
> starts["Last 5 Years"]=$(date -d "today - 5 years" ${datefmt})
> starts["Last 10 Years"]=$(date -d "today - 10 years" ${datefmt})
> starts["Last 15 Years"]=$(date -d "today - 15 years" ${datefmt})
> echo ${starts["${1}"]}
> anon@lowtide:~/code/ifs$
> anon@lowtide:~/code/ifs$ ./startdate YTD
> 01-Jan-2018
> anon@lowtide:~/code/ifs$ ./startdate "Last 15 Years"
> 01-Sep-2003
> anon@lowtide:~/code/ifs$ ./startdate "Last Week"
> 26-Aug-2018
> anon@lowtide:~/code/ifs$
I didn't show an entry I have - "Archive" - in which I call a function
that goes to the db to find the earliest post in a group.
From the Windows and Linux command line it's:
$ sqlite3 dbfile "select min(date) from table where group = 'cola';"
In bash is it just:
beginArchDate {
sqlite3 db "select min(date) from table where group = $1;"
}
starts["Archive"]=$(beginArchDate $1 ${datefmt})
anon@lowtide:~/code/ifs$ ./startdate Archive cola
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2018-09-01 22:00 +0000 |
| Message-ID | <9a0ab3.ga3or@rooftop.invalid> |
| In reply to | #465523 |
DFS <nospam@nospam.com> wrote:
> On 9/1/2018 12:28 PM, owl wrote:
>
> I didn't show an entry I have - "Archive" - in which I call a function
> that goes to the db to find the earliest post in a group.
>
> From the Windows and Linux command line it's:
> $ sqlite3 dbfile "select min(date) from table where group = 'cola';"
>
> In bash is it just:
>
> beginArchDate {
> sqlite3 db "select min(date) from table where group = $1;"
> }
>
> starts["Archive"]=$(beginArchDate $1 ${datefmt})
>
> anon@lowtide:~/code/ifs$ ./startdate Archive cola
>
That doesn't look like it's going to work.
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@nospam.com> |
|---|---|
| Date | 2018-09-01 18:27 -0400 |
| Message-ID | <%kEiD.5132$mJ1.2741@fx24.iad> |
| In reply to | #465525 |
On 9/1/2018 6:00 PM, owl wrote:
> DFS <nospam@nospam.com> wrote:
>> On 9/1/2018 12:28 PM, owl wrote:
>>
>> I didn't show an entry I have - "Archive" - in which I call a function
>> that goes to the db to find the earliest post in a group.
>>
>> From the Windows and Linux command line it's:
>> $ sqlite3 dbfile "select min(date) from table where group = 'cola';"
>>
>> In bash is it just:
>>
>> beginArchDate {
>> sqlite3 db "select min(date) from table where group = $1;"
>> }
>>
>> starts["Archive"]=$(beginArchDate $1 ${datefmt})
>>
>> anon@lowtide:~/code/ifs$ ./startdate Archive cola
>>
>
> That doesn't look like it's going to work.
It was supposed to be a question.
"In bash is it just:"
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2018-09-01 22:40 +0000 |
| Message-ID | <szbpbi3oua.gy@rooftop.invalid> |
| In reply to | #465526 |
DFS <nospam@nospam.com> wrote:
> On 9/1/2018 6:00 PM, owl wrote:
>> DFS <nospam@nospam.com> wrote:
>>> On 9/1/2018 12:28 PM, owl wrote:
>>>
>>> I didn't show an entry I have - "Archive" - in which I call a function
>>> that goes to the db to find the earliest post in a group.
>>>
>>> From the Windows and Linux command line it's:
>>> $ sqlite3 dbfile "select min(date) from table where group = 'cola';"
>>>
>>> In bash is it just:
>>>
>>> beginArchDate {
>>> sqlite3 db "select min(date) from table where group = $1;"
>>> }
>>>
>>> starts["Archive"]=$(beginArchDate $1 ${datefmt})
>>>
>>> anon@lowtide:~/code/ifs$ ./startdate Archive cola
>>>
>>
>> That doesn't look like it's going to work.
>
>
> It was supposed to be a question.
>
> "In bash is it just:"
If you're going to call it like this
./startdate Archive cola
Try something like this:
beginArchDate () {
sqlite3 db "select min(date) from table where group = $1;"
}
#...
starts["Archive"]=$(date -d "$(beginArchDate ${2})" ${datefmt})
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@nospam.com> |
|---|---|
| Date | 2018-09-01 19:09 -0400 |
| Message-ID | <PYEiD.9367$SG2.8756@fx29.iad> |
| In reply to | #465527 |
On 9/1/2018 6:40 PM, owl wrote:
> DFS <nospam@nospam.com> wrote:
>> On 9/1/2018 6:00 PM, owl wrote:
>>> DFS <nospam@nospam.com> wrote:
>>>> On 9/1/2018 12:28 PM, owl wrote:
>>>>
>>>> I didn't show an entry I have - "Archive" - in which I call a function
>>>> that goes to the db to find the earliest post in a group.
>>>>
>>>> From the Windows and Linux command line it's:
>>>> $ sqlite3 dbfile "select min(date) from table where group = 'cola';"
>>>>
>>>> In bash is it just:
>>>>
>>>> beginArchDate {
>>>> sqlite3 db "select min(date) from table where group = $1;"
>>>> }
>>>>
>>>> starts["Archive"]=$(beginArchDate $1 ${datefmt})
>>>>
>>>> anon@lowtide:~/code/ifs$ ./startdate Archive cola
>>>>
>>>
>>> That doesn't look like it's going to work.
>>
>>
>> It was supposed to be a question.
>>
>> "In bash is it just:"
>
> If you're going to call it like this
>
> ./startdate Archive cola
>
> Try something like this:
>
> beginArchDate () {
> sqlite3 db "select min(date) from table where group = $1;"
> }
>
> #...
>
> starts["Archive"]=$(date -d "$(beginArchDate ${2})" ${datefmt})
This special case 'Archive' isn't subtracted from the current date to
get the startdate. So is it:
starts["Archive"]=$("$(beginArchDate ${2})" ${datefmt})
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2018-09-01 23:59 +0000 |
| Message-ID | <g9a799aaefa.o3x12@rooftop.invalid> |
| In reply to | #465529 |
DFS <nospam@nospam.com> wrote:
> On 9/1/2018 6:40 PM, owl wrote:
>> DFS <nospam@nospam.com> wrote:
>>> On 9/1/2018 6:00 PM, owl wrote:
>>>> DFS <nospam@nospam.com> wrote:
>>>>> On 9/1/2018 12:28 PM, owl wrote:
>>>>>
>>>>> I didn't show an entry I have - "Archive" - in which I call a function
>>>>> that goes to the db to find the earliest post in a group.
>>>>>
>>>>> From the Windows and Linux command line it's:
>>>>> $ sqlite3 dbfile "select min(date) from table where group = 'cola';"
>>>>>
>>>>> In bash is it just:
>>>>>
>>>>> beginArchDate {
>>>>> sqlite3 db "select min(date) from table where group = $1;"
>>>>> }
>>>>>
>>>>> starts["Archive"]=$(beginArchDate $1 ${datefmt})
>>>>>
>>>>> anon@lowtide:~/code/ifs$ ./startdate Archive cola
>>>>>
>>>>
>>>> That doesn't look like it's going to work.
>>>
>>>
>>> It was supposed to be a question.
>>>
>>> "In bash is it just:"
>>
>> If you're going to call it like this
>>
>> ./startdate Archive cola
>>
>> Try something like this:
>>
>> beginArchDate () {
>> sqlite3 db "select min(date) from table where group = $1;"
>> }
>>
>> #...
>>
>> starts["Archive"]=$(date -d "$(beginArchDate ${2})" ${datefmt})
>
>
> This special case 'Archive' isn't subtracted from the current date to
> get the startdate. So is it:
>
> starts["Archive"]=$("$(beginArchDate ${2})" ${datefmt})
>
No, assuming your beginArchDate function returns a typical date
string, you want to pass that string to "date -d" along with the
format specifier ${datefmt}.
-d, --date=STRING
display time described by STRING, not 'now'
The $(...) expects a command. The outer $(...) in
$("$(beginArchDate ${2})" ${datefmt})
would just contain the date string returned by beginArchDate ${2}
followed by the expanded ${datefmt}, and would throw a "command not
found."
anon@lowtide:~/code/ifs$ cat -n dated
1 #!/bin/bash
2
3 declare -A starts
4
5 if [ ${#} -ne 2 ];then
6 echo "feed me a date period and a news group"
7 exit
8 fi
9
10 beginArchDate() {
11 echo "Mar 1 1999"
12 }
13
14 datefmt="+%d-%b-%Y"
15
16 starts["Archive"]=$(date -d "$(beginArchDate ${2})" ${datefmt})
17 starts["Darkive"]=$("$(beginArchDate ${2})" ${datefmt})
18
19 echo starts[\"${1}\"]: ${starts["${1}"]}
20
anon@lowtide:~/code/ifs$
anon@lowtide:~/code/ifs$ ./dated Darkive cola
./dated: line 17: Mar 1 1999: command not found
starts["Darkive"]:
anon@lowtide:~/code/ifs$ ./dated Archive cola
./dated: line 17: Mar 1 1999: command not found
starts["Archive"]: 01-Mar-1999
anon@lowtide:~/code/ifs$
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@nospam.com> |
|---|---|
| Date | 2018-08-28 23:01 -0400 |
| Message-ID | <e0ohD.279518$Yn4.158361@fx36.iad> |
| In reply to | #465331 |
On 8/28/2018 3:14 PM, owl wrote:
> DFS <nospam@nospam.com> wrote:
>> On 8/28/2018 1:21 PM, owl wrote:
>>> DFS <nospam@nospam.com> wrote:
>>
>>>> https://imgur.com/a/JWTIK
>>>>
>>>> Linux makes you stupid.
>>>
>>> Those aren't nested if statements. They are all at the same level.
>>
>>
>> I know. I didn't say they were nested - I said Feeb tried to remember
>> how many levels there were in his junky code. It's no less crappy just
>> because it's one level.
>
> If you're dealing with a bunch of ranges, a long if-else sequence
> might be the only way.
Maybe, but usually not.
And if you're dealing with a contiguous tax table (or any data where you
might have to evaluate each row and column), you always access each
element with a for..loop program. Then you most likely won't ever have
to change the code if the table shrinks or grows.
For his program (check the tax rate for an income falling within a
range), you definitely don't write an if-then-else for each row.
He should have written something like:
gross = 100000
taxVal = 0
For i = 1 To countincomeBrackets(taxYear)
minIncome = taxTable.Cells(row i, col 1)
maxIncome = taxTable.Cells(row i, col 2)
tax = taxTable.Cells(row i, col 3)
taxRate = taxTable.Cells(row i, col 4)
If gross > minIncome and gross <= maxIncome Then
taxVal = tax + (taxRate*(gross-minIncome))
Exit For
End If
Next i
Instead: https://imgur.com/a/JWTIK
maroooonnnnn!
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2018-08-29 06:26 +0000 |
| Message-ID | <l64b80a0b.q15@rooftop.invalid> |
| In reply to | #465359 |
DFS <nospam@nospam.com> wrote: > On 8/28/2018 3:14 PM, owl wrote: >> DFS <nospam@nospam.com> wrote: >>> On 8/28/2018 1:21 PM, owl wrote: >>>> DFS <nospam@nospam.com> wrote: >>> >>>>> https://imgur.com/a/JWTIK >>>>> >>>>> Linux makes you stupid. >>>> >>>> Those aren't nested if statements. They are all at the same level. >>> >>> >>> I know. I didn't say they were nested - I said Feeb tried to remember >>> how many levels there were in his junky code. It's no less crappy just >>> because it's one level. >> >> If you're dealing with a bunch of ranges, a long if-else sequence >> might be the only way. > > > Maybe, but usually not. > Depends on what needs to happen at each test case. If it's something that can be rolled up, then fine, but then you also run up against readability vs conciseness, where the most elegant code might actually be harder to follow, with no actual runtime benefit, and would likely take longer to write, just from tweaking and care.
[toc] | [prev] | [next] | [standalone]
| From | "F. Russell" <fr@random.info> |
|---|---|
| Date | 2018-08-28 19:25 +0000 |
| Message-ID | <pm47ja0ks9@news3.newsguy.com> |
| In reply to | #465275 |
On Tue, 28 Aug 2018 08:28:26 -0400, DFS wrote: > > your VBA tax "program" and tried to remember how > many levels of if-then-else shitcode you had written. > You goddamned motherfucking son-of-a-bitch! Now you listen and you listen good! I indicated that my code fragment was merely a PROTOTYPE. Do you got that? A PROTOTYPE to test feasibility. So go and fuck yourself with a cactus branch. Better yet, have a look at the source code for Microshit Assess. You'll be flabbergasted at the trash and inefficiency. That's why, unlike FOSS, they keep it hidden.
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@nospam.com> |
|---|---|
| Date | 2018-08-29 09:32 -0400 |
| Message-ID | <1fxhD.6$UI2.1@fx18.iad> |
| In reply to | #465333 |
On 8/28/2018 3:25 PM, F. Russell wrote: > On Tue, 28 Aug 2018 08:28:26 -0400, DFS wrote: > >> >> your VBA tax "program" and tried to remember how >> many levels of if-then-else shitcode you had written. >> > > You goddamned motherfucking son-of-a-bitch! > > Now you listen and you listen good! > > I indicated that my code fragment was merely a PROTOTYPE. > Do you got that? A PROTOTYPE to test feasibility. Liar. It was never a prototype - it was your production sheet for Fed and MI withholding, since 2013. All your crap code is seen starting around 5:40 in 'CrucifyDFS.mp4', still available on alt.binaries.multimedia.transformation. You revealed your incompetence and inability to address a block of data with a for loop. It's almost unbelievable. > So go and fuck yourself with a cactus branch. Never again address a block of tax data with if-then-else statements. Do you understand? > Better yet, have a look at the source code for Microshit > Assess. You'll be flabbergasted at the trash and > inefficiency. That's why, unlike FOSS, they keep it hidden. I wish I could - it would be nice to find out how they make Access such an excellent desktop db system. It makes LO Base look like kindergarten finger-painting.
[toc] | [prev] | [next] | [standalone]
| From | fr314159@gmail.com |
|---|---|
| Date | 2018-08-29 06:46 -0700 |
| Message-ID | <e6077dcc-675b-45f9-9dcf-7e50ac9bc74a@googlegroups.com> |
| In reply to | #465366 |
On Wednesday, August 29, 2018 at 9:31:45 AM UTC-4, DFS wrote: > > Never again address a block of tax data with if-then-else statements. > Isn't that rich. This supreme dunce is actually trying to give ME advice. Ha, ha, ha, ha, ha! How shall I proceed? Using his ridiculous for-loop suggestion? Ha, ha, ha, ha! He'd be laughed out of programming 101 for that bit of pure idiocy. In the context of the spreadsheet environment, the BEST solution is to exploit the built-in VLOOKUP() function, which is perfectly possible with LO Basic. The fact that the stooge COMPLETELY OVERLOOKED this most efficient solution proves, yet again, that he is not fit to participate in ANY programming endeavor. A for-loop for searching a spreadsheet cell range? Ha, ha, ha, ha! That's got to be a new record for his imbecility.
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@nospam.com> |
|---|---|
| Date | 2018-08-29 09:55 -0400 |
| Message-ID | <5BxhD.279592$Yn4.5089@fx36.iad> |
| In reply to | #465371 |
On 8/29/2018 9:46 AM, fr314159@gmail.com wrote:
> On Wednesday, August 29, 2018 at 9:31:45 AM UTC-4, DFS wrote:
>
>>
>> Never again address a block of tax data with if-then-else statements.
DO. YOU. UNDERSTAND?
> Isn't that rich. This supreme dunce is actually trying to give ME
> advice. Ha, ha, ha, ha, ha!
>
> How shall I proceed? Using his ridiculous for-loop suggestion?
> Ha, ha, ha, ha! He'd be laughed out of programming 101 for that
> bit of pure idiocy.
>
> In the context of the spreadsheet environment, the BEST solution
> is to exploit the built-in VLOOKUP() function, which is perfectly
> possible with LO Basic.
Then why didn't you use it in the first place, brainiac?
Because you didn't know how, of course.
> The fact that the stooge COMPLETELY OVERLOOKED this most efficient
> solution proves, yet again, that he is not fit to participate in
> ANY programming endeavor.
>
> A for-loop for searching a spreadsheet cell range? Ha, ha, ha, ha!
> That's got to be a new record for his imbecility.
You should've written something like:
gross = 100000
taxVal = 0
For i = 1 To countincomeBrackets(taxYear)
minIncome = taxTable.Cells(row i, col 1)
maxIncome = taxTable.Cells(row i, col 2)
tax = taxTable.Cells(row i, col 3)
taxRate = taxTable.Cells(row i, col 4)
If gross > minIncome and gross <= maxIncome Then
taxVal = tax + (taxRate*(gross-minIncome))
Exit For
End If
Next i
Instead: https://imgur.com/a/JWTIK
heh! It's always funny to see really bad shitcode.
maroooonnnnn!
[toc] | [prev] | [next] | [standalone]
| From | fr314159@gmail.com |
|---|---|
| Date | 2018-08-29 08:02 -0700 |
| Message-ID | <18e64261-b8c7-4b69-9313-7f6609162575@googlegroups.com> |
| In reply to | #465373 |
On Wednesday, August 29, 2018 at 9:55:16 AM UTC-4, DFS wrote: > > DO. YOU. UNDERSTAND? > I understand that you need to be taken out into the back alley and given a serious beating. That's the ONLY way to deal with incorrigible jackass idiots like you. > > For i = 1 To countincomeBrackets(taxYear) > ... > Next i > Ha, ha, ha, ha, ha! Fortunately for your lame, sorry ass, both VBA and LO Basic are INTERPRETED languages. For a REAL language, a COMPILED language, the compiler often makes optimizing choices such as transforming your for-loop into a sequence of if-then statements. The user can also specify that certain loops should be "unrolled" which leads to the same behavior. In short, there is no great difference between a for-loop and an "unrolled" loop sequence. But your experience has only been with that toy VBA, a language designed for children, and such subtleties totally escape your notice. What a deprived loon! Microshit does the impossible. It makes a stupid idiot even stupider!
[toc] | [prev] | [next] | [standalone]
| From | DFS <nospam@nospam.com> |
|---|---|
| Date | 2018-09-01 10:14 -0400 |
| Message-ID | <n8xiD.40842$4S3.27131@fx47.iad> |
| In reply to | #465382 |
On 8/29/2018 11:02 AM, fr314159@gmail.com wrote: > On Wednesday, August 29, 2018 at 9:55:16 AM UTC-4, DFS wrote: > >> >> DO. YOU. UNDERSTAND? >> > > I understand that you need to be taken out into the back alley > and given a serious beating. That's the ONLY way to deal with > incorrigible jackass idiots like you. Or you could refrain from showing us your crappy code that triggers alternating waves of revulsion and cackling. >> For i = 1 To countincomeBrackets(taxYear) >> ... >> Next i >> > > Ha, ha, ha, ha, ha! > > Fortunately for your lame, sorry ass, both VBA and LO Basic are > INTERPRETED languages. VBA is both compiled and interpreted. > For a REAL language, a COMPILED language, the compiler often > makes optimizing choices such as transforming your for-loop > into a sequence of if-then statements. The user can also specify > that certain loops should be "unrolled" which leads to the > same behavior. > > In short, there is no great difference between a for-loop and > an "unrolled" loop sequence. Quit lying. You have NO IDEA what happens to your if-then VBA shitcode when it's compiled. And why didn't you write your bogus tax code in "a COMPILED language"? You don't take your own advice very often. Wonder why... is it because you're a two-faced wackjob? > But your experience has only been with that toy VBA, and Java, and python, and C, and REXX, and ObjectPAL, and PL/SQL, and T-SQL, > a language designed for children, Well, your VBA code does look like it was written by a child... except even a 7-year-old child knows to use a for loop instead of multiple if-thens to address a contiguous block of data. > and such subtleties totally escape your notice. idiot > What a deprived loon! Microshit does the impossible. It makes > a stupid idiot even stupider! Does your work system say Microsoft or Linux on it? Speak up, moron.
[toc] | [prev] | [next] | [standalone]
| From | owl <owl@rooftop.invalid> |
|---|---|
| Date | 2018-08-29 15:12 +0000 |
| Message-ID | <sx118b0a0b00a.a3y@rooftop.invalid> |
| In reply to | #465373 |
DFS <nospam@nospam.com> wrote: > On 8/29/2018 9:46 AM, fr314159@gmail.com wrote: >> On Wednesday, August 29, 2018 at 9:31:45 AM UTC-4, DFS wrote: >> >>> >>> Never again address a block of tax data with if-then-else statements. > > DO. YOU. UNDERSTAND? > > >> Isn't that rich. This supreme dunce is actually trying to give ME >> advice. Ha, ha, ha, ha, ha! >> >> How shall I proceed? Using his ridiculous for-loop suggestion? >> Ha, ha, ha, ha! He'd be laughed out of programming 101 for that >> bit of pure idiocy. >> >> In the context of the spreadsheet environment, the BEST solution >> is to exploit the built-in VLOOKUP() function, which is perfectly >> possible with LO Basic. > > Then why didn't you use it in the first place, brainiac? > > Because you didn't know how, of course. > > > >> The fact that the stooge COMPLETELY OVERLOOKED this most efficient >> solution proves, yet again, that he is not fit to participate in >> ANY programming endeavor. >> >> A for-loop for searching a spreadsheet cell range? Ha, ha, ha, ha! >> That's got to be a new record for his imbecility. > > > You should've written something like: > > gross = 100000 > taxVal = 0 > For i = 1 To countincomeBrackets(taxYear) > minIncome = taxTable.Cells(row i, col 1) > maxIncome = taxTable.Cells(row i, col 2) > tax = taxTable.Cells(row i, col 3) > taxRate = taxTable.Cells(row i, col 4) > If gross > minIncome and gross <= maxIncome Then > taxVal = tax + (taxRate*(gross-minIncome)) > Exit For > End If > Next i > > > Instead: https://imgur.com/a/JWTIK > > heh! It's always funny to see really bad shitcode. > > maroooonnnnn! > How many times do you think the if statement in your code gets executed?
[toc] | [prev] | [standalone]
Page 3 of 3 — ← Prev page 1 2 [3]
Back to top | Article view | comp.os.linux.advocacy
csiph-web