« first day (978 days earlier)      last day (4016 days later) » 
00:00 - 19:0019:00 - 00:00

user55340
7:00 PM
#!/usr/bin/perl

$foo = "9";
$bar = 10;
print (($foo < $bar)?"true":"false"); print "\n";
print (($foo lt $bar)?"true":"false"); print "\n";
----

true
false
 
@GlenH7 I used to agree, then haskell taught me not only do you not need a type specifier, but you don't even need to say "var" the = is all you need
 
user55340
You can see it being used as a number context in the first conditional, and string in the second one.
 
Though as a point of practice, I only use var when I'm instantiating something. I don't do var something = someRepo.GetValidAlgosloth(); because it's not completely obvious what type something is there
 
user41796
I'm going to go blubber to myself in the corner... :-) And make a mental note to study Perl or Haskell at some point just to push the boundaries of how I view constructs
 
user55340
For some euler problems it made life easy... that number? oh, its a string now - treat it as such. Oh, its a number again...
 
user41796
7:03 PM
@JimmyHoffa - that's the type of usage I really dislike. My complaints are more surrounding the maintainability of the resulting code. While the compiler may be able to make it all work, I don't like making future developers work harder to understand what's going on.
 
here, have an algosloth, it'll make you feel better.
return new Algosloth();
 
user55340
rather than the type coercion of more disciplined languages.
 
user55340
It does lead to some unexpected behavior when you are mixing the types (the difference of "A9"++ vs "9A"++).
 
@GlenH7 when new blablabla is on the right of the equals, it doesn't make it confusing to future developers
 
user55340
And instead you need operators to work on the type itself... lt vs <.
 
user41796
7:05 PM
I think an understated benefit of explicit type conversions is that it can serve as a marker of "I'm explicitly doing this because it's needed to solve the problem." But I've also seen a fair number of errant explicit casts just to bypass a warning or compiler error
 
Yeah, now that makes me crazy, when people write in static languages and they bump their head on some type error and are just like "Oh.. uhh... well (TheTypeTheyWant)someDamnVariable there we go all better"
 
user55340
6
A: How does Perl decide to treat a scalar as a string or a number?

converter42Data::Dumper's job is to serialize data and you can't tell much about what perl is doing internally with the data based on its output. The Devel::Peek module can dump the underlying flags and values stored in the variables. The Devel::Peek POD explains the significance of the flags. #!/usr/bin/p...

 
8:05 PM
Haha, I just stumbled onto this in the review queue:
8
Q: How does Go improve productivity with "implicit" interfaces, and how does that compare with C#'s notion of Extension Methods?

Robert HarveyIn the Go Language Tutorial, they explain how interfaces work: Go does not have classes. However, you can define methods on struct types. The method receiver appears in its own argument list between the func keyword and the method name. type Vertex struct { X, Y float64 } func (v *Ver...

Funny seeing a mod's Q in close queue, but it was an audit. The audits totally piggyback off the trustworthiness of mods in their audits, I thought that might be the case before, but that's clearly the case there
 
@JimmyHoffa Robert is not a moderator (on Programmers).
 
@YannisRizos anymore?
He used to was; no?
 
@JimmyHoffa Never was. He's a moderator on Stack Overflow.
 
Ah. I thought he modded here in P.SE's earlier times.
It's ok, they say I'm touched in the head.
 
The pro temp were:
14
Q: Moderator Pro Tem Announcement

Robert CartainoThroughout the beta, we need members from the site whose focus is to engage the community, both in community-building issues and site management. That's why we select a few members from each community to act as temporary, provisional Moderators. You can read about the program here: Moderators Pro...

 
8:13 PM
I like that they used an image so you can see the fixed point 1400 rep ChrisF had. pitiful.
:D
 
I think the flair thingy didn't exist back then.
 
8:29 PM
@YannisRizos I didn't know ChrisF was a pro temp. He pro temp'd with my friend and classmate! :O
 
9:10 PM
@psr You MUMPS guys always try putting everything in the database..
 
user55340
9:34 PM
@JimmyHoffa hows my functional here (playing with the compute pi sequence))?
 
user55340
(defn everyother-from [n]
  (cons n (lazy-seq (everyother-from (+ n 2))))
)

(defn neg [n] (* n -1))

(float
  (* 4
    (reduce +
      (map #(%1 %2)
       (cycle [identity neg])
       (map recipical (take 1000 (everyother-from 1)))
      )
    )
  )
)
 
what's recipical?
(range 1 1000 2) <-- this will do your everyother-from
 
user55340
(defn recipical [n] (/ 1 n))
 
(range start stop increment)
 
user55340
... and range is nicely lazy. Yep, better form.
 
user20683
9:43 PM
today I bought fairly nice clothes
 
user20683
it hurt my wallet
 
user55340
Suspenders?
 
@WorldEngineer been there.
 
user20683
@MichaelT I already own a belt
 
user20683
I might consider suspenders at some point
 
user55340
9:44 PM
Back in the boom days, I went to an interview in a black T-shirt and jeans... didn't even bat an eyelash.
 
@MichaelT I'm unfamiliar with a map that takes 3 parameters?
 
user55340
@JimmyHoffa which map call is that?
 
user20683
@MichaelT medium beige slacks, nice slate grey shirt, dark socks, black leather shoes
 
user55340
Ahh... the (map #() () ()) form?
 
(map #(%1 %2)
   (cycle [identity neg])
   (map recipical (take 1000 (everyother-from 1)))
 )
 
user20683
9:45 PM
might go get a cotton sport coat I saw if I can't find and get my old one cleaned
 
user55340
You can also see it in
 
user55340
14
A: Clojure: Call a function for each element in a vector with it index

Arthur UlfeldtYou can get the same effect in a very clojure-idiomatic way by just mapping the indexes along with the data. (map #(setCell 0 %1 %2) (iterate inc 0) data) You may want to wrap this in a (doall or (doseq to make the calls happen now. It's just fine to map an infinite seq along with the finite o...

 
user55340
Nice, I didn't know this behavior of map when applied to multiple collections. — pmf Oct 31 '09 at 7:30
 
@MichaelT so you're cycling the index, then the negative of the index? Or the value and then the neg of the value? Is it like a composition (compose: f . g = f(g(x)) ) of the first function with the second function?
Oh is it a condition?
 
user55340
9:53 PM
pi = 4 * (1 - 1/3 + 1/5 - 1/7 ... )
 
so it's a composition
map f g xs = map (f.g) xs
 
user55340
Btw, @WorldEngineer some comments/corrections for the latest blog post exist in the blog chat room.
 
user20683
@MichaelT I saw, will get to them asap
 
user20683
remember I graduates on teh Fridays
 
user20683
got to take care of a few things first
 
user20683
9:55 PM
also in theory I co-run the blog
 
user20683
where is my co-runner?
 
@MichaelT Thank you for volunteering to co-run the blog.
 
user20683
@YannisRizos I thought Morons volunteered
 
user20683
kinda
 
user55340
(rats! I can't delete that message anymore...)
 
user20683
9:57 PM
@MichaelT which one?
 
user55340
The one that made @YannisRizos think that I volunteered.
 
I think I see what you were trying to do there @MichaelT, I would think maybe..

(+ (reduce + (map recipical (range 1 1000 4)))
   (reduce - (map recipical (range 3 1000 4)))
 
user20683
@MichaelT better?
 
user55340
(heh... I was mostly joking...)
 
Does that make sense?
 
9:59 PM
@WorldEngineer Dynamic showed up on Meta today, but haven't seen him in chat for quite some time. You could perhaps super-ping him in the blog chat room and discuss running the blog.
 
user20683
@YannisRizos yeah or I could just continue my defacto dictatorship
 
user20683
:P
 
Is the reciprocal of -3 -1/3?
 
user55340
Yep.
 
user20683
the inverse is 1/3
 
10:01 PM
@WorldEngineer Your dictatorship is safe: You have a diamond next to your username.
 
user20683
@YannisRizos yeah
 
user55340
Reciprocal is across all real numbers, and it is 1/n (undefined at 0)
 
(reduce #(+ (recipical %1)) (concat (range 1 1000 4) (map neg (range 3 1000 4))
 
user55340
So reciprocal(-3) --> -1/3
 
user55340
and apparently, I spelled it wrong.
 
10:03 PM
@MichaelT Yeah, I was ignoring that
:)
Yeah, I like that last one there.
 
user55340
Is there a 'reduce until' type thing?
 
In haskell you always just take n and pass that to your reduce/map/etc
or use ranges as [1,5,..] etc
 
user55340
I stumbled across Yanni's old controversial blog post and decided to tackle the (compute pi to 5 digits of accuracy)... while I've got the "run it" I don't know how to implement the "until"
 
@MichaelT the range is your until
OHH
 
user20683
@MichaelT I did figure out how to do Problem 315
 
10:05 PM
I see what you mean
yeah there is..
 
user20683
Set Theory makes it stupid simple
 
user55340
Given that Pi can be estimated using the function 4 * (1 – 1/3 + 1/5 – 1/7 + …) with more terms giving greater accuracy, write a function that calculates Pi to an accuracy of 5 decimal places.

It’s a problem that should make you think, but shouldn’t be out of reach to a seasoned developer (it can be answered in about 10 lines of C#). However, many of our (supposedly pre-screened by the agency) candidates couldn’t even begin to answer it, or even explain how they might go about answering it. So after a while I started asking simpler questions like:
 
user55340
#18 from the list.
 
user55340
Yannis Rizos on August 29, 2012

One of the very first ideas we had for this blog was to convert some of the wonderful gems of the early era of our site, the undisciplined period, to blog posts. Questions that were once enthusiastically received by the community, but no longer fit Programmer’s scope.

The first deleted question I’ve chosen is Jon Skeet’s “What’s your most controversial programming opinion?” question (available only to 10K+ users, sorry), a +391 scored question that was originally asked on Stack Overflow on January 2, 2009. What follows are twenty of the highest voted answers, in random order… …

 
user20683
@MichaelT taylor series but I'd need to look at the function in my calc book to actually write it and figure out how many terms I'd need for that error
 
user55340
10:07 PM
and I kind of had an XY problem there... though I wasn't tackling the other part of it yet, just getting the part I knew down to be able to think of it.
 
@MichaelT Actually I can't think of a standard function for that, I think you just need to recurse for it
 
user20683
:See Leibniz (disambiguation) for other formulas known under the same name. In mathematics, the Leibniz formula for , named after Gottfried Leibniz, states that :1 \,-\, \frac{1}{3} \,+\, \frac{1}{5} \,-\, \frac{1}{7} \,+\, \frac{1}{9} \,-\, \cdots \;=\; \frac{\pi}{4}.\! Using summation notation: :\sum_{n=0}^\infty \, \frac{(-1)^n}{2n+1} \;=\; \frac{\pi}{4}.\! Names The infinite series above is called the Leibniz series. It is also called the Gregory–Leibniz series, recognizing the work of James Gregory. The formula was originally discovered by Madhava of Sangamagrama in the ...
 
user20683
This thing
 
user20683
you use this thing then figure out the error
 
user20683
and then sum it that far and no further and done
 
10:08 PM
(reduce #(+ (reciprocal %1))
        (concat
         (range 1 1000 4)
         (map neg (range 3 1000 4))))
 
The Indiana Pi Bill is the popular name for bill #246 of the 1897 sitting of the Indiana General Assembly, one of the most famous attempts to establish mathematical truth by legislative fiat. Despite that name, the main result claimed by the bill is a method to square the circle, rather than to establish a certain value for the mathematical constant π (pi), the ratio of the circumference of a circle to its diameter. However, the bill does contain text that appears to dictate various incorrect values of π, such as 3.2 (π = 3.14159265...). The bill never became law, due to the int...
 
That's my final answer.
for the 1000 issue
 
user20683
@YannisRizos proving that American Legislators being total F****** morons isn't a new thing
 
user55340
It does make it easy to do the calculation to 5 digits. 3.2 we're done.
 
user55340
Another fun pi bit - poems to encode the number to make it 'easier' to memorize.
 
user20683
10:11 PM
there's an even easier way to get 5 digits of accuracy
 
user55340
 
user20683
I know the first 6 sheerly because that's what I used to do my physics spreadsheets with
 
user55340
@JimmyHoffa The recursion approach makes sense.
 
(defn piToFive [current terms]
  (if (= 3.14159 current)
    current
    (let [newTerms (cons (* -1 (+ 2 (first terms))) terms)]
      piToFive (reduce #(+ (reciprocal %1)) newTerms) (newTerms))))
Something like that
 
user55340
Nah, I should look at the current term and decide if it has no impact on the digits in the decimal places... or something like that.
 
10:17 PM
? it adds terms to the calculation until it hits the first 3.14159 which is what you want, right?
 
user55340
Except that I don't want to encode the answer in the code...
 
user55340
So it should look at the term and decide if it is done, just by looking at the term.
 
@MichaelT yeah, that part I can't help with; sounds far to mathy. Not sure how you test accuracy otherwise
 
user55340
Its mathy.
 
(defn isPiWithinFive [val] (...no idea...)) and use that instead of 3.14159
 
user55340
10:20 PM
Though a guess would be... "take the rational as a float, as a string, substring, and compare to 0.00000"
 
user55340
Or could just compare it to less than 1/10^5
 
psr
@JimmyHoffa - I do tend to put a lot in the database. Sometimes instead of a class hierarchy I end up breaking the variation into meta-data tables and composing the object out of them. As I would likely do to handle the units of measure situation - I would make each dimension a row in a database rather than an interface.
 
@psr I was just giving you crap, I actually really like living in the DB, you can do a lot there knowing it's going to perform amazingly, and written cleanly it's really no train wreck
But you didn't hear that from me, I'm a .NET guy, crud-orm's and services for the win! Yeah...
 
psr
@JimmyHoffa You don't need to write the code in the DB to do it this way - I've done it in C#. The point is the behavior varies by instance, not class.
You make the behavior much more meta and use the meta instances to control things. In the example, there might be some reason to know you are specifically working with length, but I would strive to avoid that by making the meta-model more capable.
However, this might in part be a habit formed in working without objects being available, where running off of meta-data is one of the ways you can keep things sane.
 
11:09 PM
@MichaelT This sounds like an imperative approach, the function itself should look at the term, you shouldn't decide ahead of time what parameters to give to your function that will induce it to give the correct output
 
psr
11:50 PM
@JimmyHoffa - You are against a tolerance parameter value being passed to the function?
 
user55340
@psr That's what I was thinking...
 
00:00 - 19:0019:00 - 00:00

« first day (978 days earlier)      last day (4016 days later) »