« first day (854 days earlier)      last day (3165 days later) » 

2:00 PM
@skiwi really I do not know
 
Now our general function can naively be implemented as follows:
general [] = n
general (x:xs) = x op (general xs)
 
1) op = (+); 1 op` 3 = 4`
@Conrad why didn't you define the op paremeter?
 
It is more of a general thing. Of course you'd have to provide it.
 
Wait, this is fold right?
 
However, the exact operator is more of a natural property of the underlying monoid. For example the strings have concatenation. For integers it could either be addition or multiplication. You have to provide n as well. ;)
Fold or reduce, yes. (:
 
2:03 PM
The neutral is used as a start right?
 
Yes.
 
fold op start [] = start
The base case is easy
 
You can look the real implementation up on the internet.
You obviously do not want to use the naive implementation I gave you, as it is not tail recursive.
 
I wrote it!
 
The category theory bit in here is simply showing the underlying similarities between different types that share some properties, like the operation and the neutral element.
 
2:07 PM
fold op start [] = start
fold op start (x:xs) = fold op (start `op` x) xs
 
Kewl.
One other cool thing you could note is, that folding does not only work with lists itself.
Lists itself are monoids, so we can fold lists of lists as well.
 
Anything made out of head and rest can be folded
 
The neutral element is the empty list and concatenation is list concatenation.
Even more! You could fold binary trees as well.
 
my_concat = fold (:) [] :( does not work. Cannot construct infinite type...
 
List concatenation is (++).
my_concat = fold (++) []
 
2:13 PM
@Conrad beatiful
(:) is consing
prepending an item onto a list
 
List construction. Exactly.
This does not quite work with our folding. We need an op with
op :: a -> a -> a
However:
(:) :: a -> [a] -> [a]
 
0
Q: Function for timing executions (inspired by MATLAB tic toc)

IdefuxInspired by MATLAB's tic/toc I've written a short helper function for calculating execution time. from time import time def tic(): """Simple helper function for timing executions. Returns a closure that holds current time when calling tic(). Usage: toc = tic() //some code ...

 
op is a binary operator, like the four basic "+" "-" "/" "*" exponentiation "^" log ...
I got a problem
common xs ys = filter (elem` ys) xs`
 
Yeah. But imo folding only makes real-world sense for commutative operations.
 
If i want to fold over common, which is the start?
 
2:21 PM
Let us take a look at the definition. ;)
 
My first try is: noStartFold op (x:xs) = fold op x xs
 
You have your operation common which - I assume - returns common elements of two given lists.
 
yes
 
Now start needs to have the following property for ALL lists xs:
xs `common` start = xs
Can we find such a start?
 
The list must contain all the existing items
 
2:22 PM
Exactly!
 
So we need a workaround
 
So either you stick with an implementation that does not need a start element, or you have a problem.
In theory you do not need a workaround. Having a list of all elements is just fine.
But in practice this won't work out well.
 
Workaround developed: noStartFold op (x:xs) = fold op x xs
 
It is called foldl1 in Haskell if I'm not mistaken.
 
Haskell has such short names..
 
2:25 PM
Yeah.
It's okay I guess.
 
ello @EthanBierlein
 
fold is descriptive.
The l in foldl means we're foldig from the left.
 
@Quill ello m8
 
And the 1 means the list has at least one element.
foldl1 will fail for empty lists.
 
Official fold from the Prelude:
 foldl            :: (a -> b -> a) -> a -> [b] -> a
 foldl f z []     =  z
 foldl f z (x:xs) =  foldl f (f z x) xs
SO similar to mine
just shorter names
foldl1 f (x:xs) = foldl f x xs
 
2:27 PM
Sure. (: Once you get the idea behind functional programming and category theory, implementing such functions becomes very mechanical and straight-forward.
 
This is so similar too
 
You could try your skills with implementing map and filter by hand. ;)
 
map f [] = []
map f (x:xs) = f x : map f xs
filter is easy too
filter f [] = []
 
It will work, but you will see this is not the same as the reference implementation.
 
reference:
It really is the same :)
 
2:30 PM
It is a bit more complicated to achive tail-recursiveness.
 
You may take a look at it, it is very straightforward (for the most part)
 
I'm shocked. :D
Okay, it seems that lazy evaluation in Haskell irradicates the usual tail recursion problem.
 
Well the exponentiation implementation is real hard, I even asked a question about it on SO: stackoverflow.com/questions/32270902/…
 
Lazy evaluation does not work with numbers, so you have to optimize a little.
 
2:35 PM
46 thousand answers, and just 5 reference that comic. I'm shocked and disappointed.
cc @Phrancis.
 
@RubberDuck Shocking!
 
lol
 
I understand, high speed numeric code is the hardest to understand in general
 
Even if you write your functions like fold and map recursively, they will not really result in recursive calls on your machine. The Haskell compiler simply converts them into a while loop.
 
I wrote 0.43% of the answers of CodeReview, cool (200 / 46000)
@Conrad are you talking about tail call optimization?
 
2:37 PM
Yes. That's what I mean by tail recursion.
 
Oh. Wow. I've written over 400 answers... I need to get a life.
 
Greetings
 
1600 / 200 = 3 / 0.43
 
Maybe I did the math wrong.
 
2:39 PM
cough no offense @200...
4
 
@EthanBierlein 1600 / 200 = 3 / 0.43
 
That is about 8, so we are both right
 
Okay. So, you'll need to peek at Ethan's removed message for that to make sense now...
 
oh wow, I've written 599 answers.... I need to write 401 more.
 
2:41 PM
@Mat'sMug Good luck :D
 
lol...
I've only written 140
How on Earth I got to 8K with that, I don't know.
 
@Ethan only everything is relative as Eninstein said
 
I wrote 40 answers
 
191 rep till 2k
 
@EthanBierlein the average votes of your answers must be more than mine
But I have more answer
 
2:43 PM
@Caridorc I smell an SEDE query.
 
@EthanBierlein I never learnt SQL
 
The basics are quite easy, but I never got the advanced stuff down either.
 
I'm still learning it.
I still have a fair amount left.
 
@EthanBierlein Probably with a couple of questions as well.
 
2:44 PM
@Mat'sMug [When are you going to get that [Socratic] badge?](codereview.stackexchange.com/users/23788/…)
 
@Mast Yeah, like that recent one with +18 votes.
 
@RubberDuck hopefully with my next question :-)
 
@RubberDuck He's been putting that on hold for quite some time now.
 
@RubberDuck he already has more than 100 questions right?
 
@Caridorc they need to be asked on separate days
 
That ^
 
@Mat'sMug interesting, that is one though badge. I asked 65 question
55 or 60 separate days
 
Yeah. I've a long way to go yet. Refiner and Copy Editor are next up for me. Maybe . We'll see.
 
2:53 PM
@RubberDuck I think I lost control of the refactoring in my branch/fork. I mean, I got the architecture set up, but only the unit testing works for now.
I'm falling prey to scope overflow
i.e. refactoring turned into a rewrite; including the WinForms UIs redone in XAML
I think I should create a dev branch in the main repo, and merge it there
Thoughts?
 
@RubberDuck My name is Bond, DROP TABLE ENEMIES; Bond
7
 
@Caridorc You forgot to commit
 
@IsmaelMiguel commit?
 
Commit the transaction
(It sounded funnier in my head)
 
@IsmaelMiguel you mean: My name is Bond, DROP TABLE ENEMIES; Bond, authorized to COMMIT CHANGES
 
3:02 PM
Something like that
It sounded funny
But nevermind
I'm retreating back to <lurking>
 
That would be licensed to kill commit
9
 
I think I'm going crazy.
All I've been reviewing lately is C++.
 
Reviewing C++ does that?
 
twitch yes twitch
 
Try VBA
 
3:06 PM
@RubberDuck hahaha Little Bobby Tables
 
Welcome to CodeReview, I love when the first post is an answer — Caridorc 36 secs ago
 
(Monking)
 
Monking @Phrancis
 
I am getting crazy: what does monking mean?
 
@Caridorc Greetings
That's what it means
 
3:07 PM
22
A: What's a Zombie? And what are the many other memes of Code Review?

Vogel612Meme: Monking Originator: Morwenn Cultural Height: The 2nd Monitor Background: A morning greeting to the Monkey doing his monkey-business, in other words: monking Examples: A small chat search Variations: Monkernoon, Monkevening, Monknight, ... Important is only that it begins with Monk... ;...

 
Ah, it was easy
1
Q: Monoalphatic and Polialphabetic cipher in Ruby

CaridorcThis code encrypts a text with mono-alphabetic and poli-alphabetic substitutions ciphers. For further info see: Mono-alphabetic/Caesar Cipher Poli-alphabetic cipher require 'arrow_test' ALPHABET = ("a".."z").to_a # Moves a letter forward in the alphabet by # the given key wrapping aroun...

This zombie of mine is almost an egiptian mummy
 
on the subject of SQL injection, I was playing around with sqlmap today
that was fun
 
Maybe I will place a bounty on it
who knows..
 
@Caridorc that'd be a good idea
 
I've never had any of my questions go zombie.
Maybe my code is too easy to review?
 
3:11 PM
not necessarily
your questions are probably just more interesting
I had a badly written PHP scraper go zombie
it was exceptionally easy to review
 
Huh
I never thought of it that way.
 
@Quill bounty placed, now I just have to wait
 
@Caridorc That's only 1 month old...
5
Q: PHP function to create a Hex dump - Followup

Ismael MiguelThis is a followup of the following question: PHP function to create a Hex dump @Corbin made a very interesting review, and I re-wrote most of the code. function hex_dump( $value ) { $to_hex = function( $number ){ $hex = strtoupper( dechex( $number ) ); //if we don't check ...

3 months old
 
@IsmaelMiguel Usually I get a review within a day or three so a month is a loong time
 
Usually, it is the same with me
 
3:14 PM
@IsmaelMiguel To be fair, I've had it starred to answer for about half that
I've been meaning to answer it
 
@Quill You're free to answer it at any time
 
0
Q: Suggest me remove bad things for Speed Performance optimization

Pankaj GargMy Project Manager are saying that there are many bad things in my code. But they are not helping me to correct it. can you please suggest me to remove bad things from the code ? I have 7 Project in my Solution that do a particular database Interaction job. Here are the details Project - 1 - Ob...

 
I promise I'll answer it 6 or 7 days
 
It had an answer, but the answer was basically "Use recursion"
 
@CaptainObvious he tried to fix my comments
 
3:15 PM
With a copy of my code
Thanks, Santa!
 
@IsmaelMiguel you are welcome
 
@Quill If I don't get around to it in 6 or 7 days, I'll bounty it.
I most absolutely promise
 
@Quill Don't
Don't waste reputation
 
Why, it's the highest voted PHP zombie IIRC
 
Six more votes and you will refund me the bounty cost, nice :)
 
3:17 PM
@Quill: Sir, This is MVC4. I apologize for that and I removed the unnecessary tags — Pankaj Garg 29 secs ago
@Caridorc or you could write an answer and make it three ;-)
 
@Quill I got no ideas for improvement on that one
 
*On another question
just any ole question
 
@Quill Well, if a bounty of 100 leaves a question unanswered for 8 months...
 
@RubberDuck: There are 7 different Projects — Pankaj Garg 47 secs ago
@RubberDuck ^ wow
 
Yeah. I know @Quill.
I don't know who voted to close it, but I'd like to hear their reasoning. It's just a language barrier.
 
3:24 PM
@CaptainObvious Suggest me to remove bad title
5
 
Bye people, see you later!
 
@RubberDuck yeah, people ought to enquire before CVing
@Caridorc later
 
sigh Why does this guy have 7 projects? Where's that "interesting mathjax" meta? I need to draw a picture....
 
I like how this guy refers to us as Sir
 
Good thing that there are no ladies around
 
3:37 PM
Yeah. Emily would shred him...
I don't even know where to start with this one.
 
0
Q: Dijkstra's shortest path algorithm in C

coderoddeNow I have this C implementation of the famous algorithm: dijkstra.h: #ifndef DIJKSTRA_H #define DIJKSTRA_H #include "directed_graph_node.h" #include "weight_function.h" #include "list.h" #ifdef __cplusplus extern "C" { #endif list_t* dijkstra(directed_graph_node_t* p_source, ...

 
I'm sure Emely isn't that bad
I hope
 
Okay. One more question. (Two actually). Is there more code in these projects? Did someone specify this design for you, or did you come up with this high level design yourself? (Not the code, I know you wrote the code, I mean the architecture.) — RubberDuck 1 min ago
She's a genius, but gets touchy about improper honorifics. =;)-
 
"Improper honorifics" --> What does that mean?
 
3:46 PM
@IsmaelMiguel it means she's a genius programmer living in "a man's world". There's a meta somewhere, but I've gotta go.
 
0
Q: Merge Sort without pointers in C

Stefan RendevskiAs part of an online course exercise, I was supposed to implement Merge Sort in C. Pointers were still not discussed prior to this exercise, so I have to work with arrays. Memory efficiency is not something I'm supposed to be focused on. #include <cs50.h> #include <stdio.h> #define DEBUG void ...

 
I have to go as well, but I'll be around
 
4:04 PM
And I'm back
 
hello
 
Greetings dude
 
@RubberDuck jamal just burned the cabdudates down to 20..
 
4:29 PM
0
Q: Number of common divisors [Spoj]

AnkurI am getting wrong answer for this solution on SPOJ for the question: http://www.spoj.com/problems/COMDIV/ although my soultion is working for all the test cases i tried. my approach: Find gcd of two given number. To count number of divisors: let say the calculated gcd has prime factorizati...

 
@Vogel612 cabdudates?
blames phone chat
 
no... actually I have a keyboard..
I just didn't really watch it..
candidates*
 
anyone ever see this before? its linking to stack exchange questions and has ads on it
 
oh boy
Time to report another site for copyright violation
 
I've seen sites posting SE Q/A's without citation, too.
 
4:41 PM
done
The site technically provides a link to the question on SE, but that's not really "attribution".
 
@EthanBierlein All users are copied to their site, so it's bad indeed.
 
agreed
 
They even copied the vote buttons, but those don't do anything.
"This presentation of data is completely legal and follows all the attribution requirements of relevant sites mentioned here."
Yea, right...
 
0
Q: overwriting current score with highest score

user83840I made a memory game and I want to create a condition for the score. if a user completes the game and enter his name it displays the time he completed and the name in the scoreboard form, I was able to do it but I want a code or an idea for another user completed with the least time to overwrite ...

 
> Source Link: Stack Exchange
 
4:47 PM
@Mat'sMug Except they don't follow all the requirements.
 
right
and the answers don't seem to correlate to SO answers
weird
 
Well, they're still copying without attribution, so even if the answers are mixed up, it's still worth reporting.
 
agreed
 
@Vogel612 that was @rolfl actually. I'd forgotten to specify is:q in the search.
 
Keep an eye on this user:
May be a hidden-gem generator, but may also be posting dubious content instead.
I think he'll get it.
 
4:54 PM
why was his first answer deleted?
 
@EthanBierlein actually...
@bazola the user profiles link back to SE...
 
@Mat'sMug I don't know, can't see those.
 
0
Q: Find a triangle in a graph represented as an adjacency list

AxlI have a graph represented as an adjacency list. I need to find a triangle in this graph. A triangle is a triple of vertices u, v and w, such that (u, v), (v, w) and (u, w) are edges of the graph. The graph does not necessarily needs to be undirected. I found the following pseudocode for solving...

 
@Vogel612 meaning?
 
also there's a source link
meaning it's not illegal what they do.
 
you aren't allowed to use SE content to make money though are you?
 
the posts also link back
you are
 
@bazola I dont think so
 
it's CC-BY-SA, not CC-BY-NC
 
@Vogel612 No
2 mins ago, by Mast
@Mat'sMug I don't know, can't see those.
 
4:57 PM
Oh, yeah, I forgot I was that far ahead of you.
 
@Mast that user is one of theirs
content posted by them is not posted on the SE posts.
 
@Vogel612 His activity links to SE comments.
 
any way, OP edited/expanded their answer after it was community-deleted. I find the deletion was a bit harsh
 
@Hosch250 171 to go
 
@Mast I don't know if I ever capped on a Saturday
 
4:59 PM
@Mast not from what I can see
it seems to be okay by copyright laws to me
 
well, reporting it can't hurt anyway. if it's not warranted, SE won't act on it. if it is, then SE knows about it
5
 
5:11 PM
Since your code works, this would be a great question for codereview.stackexchange.com — Prescott 35 secs ago
 
Monking! :-)
 
Monking @ambigram_maker!
 
@Duga definitely true
 
I wanna know if public static variables like in here should be in camel case, or in caps. I've been thinking that I should make them private instead. Advice?
 
something could be static but not also constant
 
5:14 PM
yes
 
as long as its constant then having it in ALL_CAPS is correct i believe
 
should I add getters and setters?
 
@Mat'sMug Sounds like the Sunday Driver song by the Corries.
 
if its going to have getters and setters, it sounds like it shouldn't be static
 
it's a library
touche
;-)
Also, if I fix my code, should I post it in a new Question or as an update to the existing one?
 
5:19 PM
New question unless the old doesn't have answers, I think the usual suggestion is.
 
@ambigram_maker When in doubt, new question.
Never invalidate existing answers.
6
 
5:59 PM
Welp, here goes.
I'm going to create a code editor.
 
Zak
hi guys
 
Greetings
@EthanBierlein For what language?
 

« first day (854 days earlier)      last day (3165 days later) »