« first day (2431 days earlier)      last day (2422 days later) » 

4:05 AM
@Downgoat is basically getter
@Downgoat also yes PyTek does this
 
@ASCII-only It literally is a getter, but in expression-body form.
 
@Pavel IIRC we're already doing that
 
Mm. Do functions have expression-body form?
 
4:32 AM
Not sure
Haven't really done much on functions haha
But we're definitely going to include that
 
0
Q: Logical Puzzles related to tree structure

KathirThere are numerous programming problems are related to tree structure. example, displaying the hard drive, displaying a dropbox content, categorization, tree editors etc., example, displaying 1,000 records in a tree will fail. however it can be resolved via breadcrumb which is very efficient as...

 
Language idea: foo(a, b) is syntax sugar for foo(a)(b) and (a,b)=> is a=>b=>. If a function normally takes two operators, you can call it with one, save that result for later, and then call it with the second operator. The uselessness of this feature is astounding, I'm sure, but intresting to consider anyway.
 
It'd be nice so you can do add(1,2) or add2=add(2); add2(1)
 
@Pavel ... that means you can't do overloads...
 
@Pavel isn't that just haskell?
 
4:42 AM
IDK haskell
 
@Pavel Also. This is what & is for (IIRC)
 
@ASCII-only C got along just fine without those
 
@ASCII-only What's that
 
@Pavel ... doesn't mean it was very nice having no overloads...
 
4:43 AM
@LeakyNun Right but haskell doesn't convert functions with multiple args to a curried function automatically
 
@Pavel (f&2)(...args) == f(2,...args)
 
What language is this
 
Me equa.lua library is implicitly curryable :P
 
 
@Pavel Cheddar, but pretty sure VSL will do this too
 
4:45 AM
require"equa"
local add = x+y
print(add(3)(4))
Returns 7.
And add(3,4) does too.
 
Lua is a terrifying language.
 
That's just me abusing lua
Sane lua won't let you do that.
I wrote it because anonymous functions in lua are too bulky.
function(s)return s:rep(3)end becomes #rep(s,3)
The # just casts it to a function, to make it more compatible with standard lua functions.
 
@Pavel Where is this from?
@ASCII-only Works in J. In APL, that's .
 
@Adám Makes sense :P
 
@Adám discord dm.
We were talking about spaceships and I mentioned grade up/down
 
4:53 AM
@Pavel Ah.
 
TitleCase = gsub(s,"(%w)(%w*)",#(upper(x)..lower(y))) Titlecase func! :D
(I like this library too much)
 
@ATaco Dyalog APL: TitleCase←'(\w)(\w*)'⎕R'\u1\l2'
 
With credit, it's still a lot shorter than lua's default solution of TitleCase = function(s)return s:gsub('(%w)(%w*)',function(x,y)return x:upper()..y:lower() end)end
 
@ATaco But what do all the sugar chars do? (s,,#(..))
 
Well, in lua .. is the concat operator, simple enough.
 
5:02 AM
I'm not sure how my spaceship koth would work anymore
 
@Adám So ⎕R returns monadic function?
 
s is a protoexpression, as defined by the library.
#() casts another protoexpression to a function, which gsub can use.
# is just the length operator, but I took control of it.
 
@Pavel Actually, it returns an ambivalent function. Used monadically, it does the expected PCRE replace on the given string(s). Used dyadically, it reads from the right-arg file and outputs to the left-arg file.
 
When the function is called, it substitutes s (the only protoexpression it has access to), with the argument. We'll say "Hello, world!" for this case. then, the expression is gsub("Hello, world!", '(%w)(%w*)', #(upper(x)..upper(y))). This is satisfactory for gsub to run (because it thinks the third argument is a function, not a protoexpression), so it passes the replacement args in each case to the function, which substitues x and y for each match. If that makes any sense.
 
@Adám When you say file you mean actual storage file or is than an APL term?
 
5:07 AM
@Pavel An actual file on disk.
 
Huh. That's a little odd, actually.
 
@Pavel Why?
 
Well normally built-in functions don't directly operate on files, I guess.
You'd generally always go through a File.Write call or equivalent.
 
@Pavel APL system functions (begin with ) often do.
 
Ah, right. Forgot about ⎕ being System.
Which sorta makes me wonder why ⎕A yields the alphabet.
APL is a weird language.
 
5:12 AM
I was going to do another text dump on my protoexpressions, but chatexchange was like "That's a little large there taco", and I was like "Yeah, good point"
 
@Pavel Why? names can be constants, variables (including namespaces and classes), functions, or operators.
 
"Alphabet" doesn't look like a system constant.
 
What system cares about the alphabet :P
 
I do find that it comes in handy for quickly doing base conversions, column header generation, etc.
 
Not denying it's usefulness, it's just curious that it's a system variable, rather than some other constant table.
 
5:18 AM
^
 
@Pavel Try it online! using a nice selection of system names.
 
@Pavel System.String.Alphabet :P
 
Cool. Also, TIL how to use NTIE/NCREATE
@ASCII-only /o_o
 
@Pavel Not actually a thing, that would just be its equivalent in C# if it existed
 
No I understand
 
5:37 AM
ok so I thought of an rps variant that could possibly be used for a koth
 
@DestructibleLemon umop.com/rps101.htm :P
 
@ASCII-only I can't access this at this time
 
@DestructibleLemon web.archive.org
 
@ASCII-only that was not it and also that game is not actually that cool for a koth tbh
 
@DestructibleLemon Hence the :P
 
5:42 AM
what I was thinking is that you have tokens for each attack, and when you're out of tokens for an attack you can no longer use it
speaking of which this could be combined sort of with rps 101, or higher
maybe I will actually sorta use RPS 101 for this idea
 
@Pavel Nice. There's a whole family of them. See help.dyalog.com/16.0/Content/Language/System%20Functions/… under Native Files (hence the ⎕N…, and as opposed to APL component files)
 
Thanks
 
6:03 AM
0
Q: Why doesn't this regex match what is intended

Fadai MammadovI have rules for valid email address. A username must begin with an alphabetic character. It may be followed by any number of additional alphanumeric characters or any of the following special characters: . (period), - (hyphen), _ (underscore), or + (plus). A domain name must end with an alphabe...

-1
Q: Input number and set them in lowest and highest order and sum up order

Marcos RivasI need a program that will accept numerical inputs from the user until they enter a zero. The program will track some information about the numbers the user inputs and will display these after the user has finished entering new values. It will also perform some basic statistics on the inputs and ...

 
> immidently
TBH it's not that different from how JS does it
 
JS lets you do ``, but that's it.
Lua lets you use All the constructors!
(Besides functions and numbers)
 
@ATaco Ruby lets you define method_missing, which operates on data when no valid method is provided.
So you can do that but without needing to add the w.
Or even quotes, for that matter.
 
Example?
 
I don't really have time to watch a talk.
 
It's 4 minutes and it's the best thing you'll see all day.
 
@ATaco your loss
 
(I'm at work, my manager would be pissed if they caught me)
 
@Pavel Why is this linked so often D:
 
6:19 AM
@NewMainPosts Hey look a double whammy of off-topicness!
 
@ASCII-only because it's so good
 
@ASCII-only Because I can't get it to work on my machine so I link it every time I tell people about method_missing
 
Well at least lua has consistency :P
 
Yeah, there is the fact that Ruby like to introduce breaking changes a lot.
And occasionally not tell anyone about it, except to remove a function from the docs.
 
Come home to simplicity, come home to Lua.
 
6:21 AM
And then redefine that function to always return 0 instead of removing it.
With the justification that "An undocumented function can do whatever it wants"
 
@Pavel example?
 
@JohnDvorak Object#methods, and actually it returns an empty array, not 0. It was replaced with a different method.
 
Well... if it was undocumented...
 
CMC : Wat in your language of choice.
 
What do you mean by, wat?
 
6:26 AM
@ATaco Simple expression with unexpected answer.
 
@JohnDvorak But it was documented in 1.x, and it did what was expected.
Then they removed it from the docs without telling anyone, and replaced it.
@Adám Lua, x bytes: Literally anything as far as I can tell
 
@JohnDvorak Not just Ruby and JS, obviously.
 
@Pavel the real wat here is what you apparently think "literally" means
 
@Pavel This is only if you do to it what I do to it.
 
6:28 AM
@JohnDvorak Every example of Lua I've seen in my life has been ATaco demonstrating a new wat.
So I feel justified in saying that.
 
Then you should look up some real code
 
¯\_(ツ)_/¯
 
require"equa"
func = b^a+c
print(func(3,2,1))
Returns 9.0
 
6:30 AM
s/-/:
Edit ninja'd
 
@Pavel Can't get what to work
 
method_missing.
 
@Pavel You forgot the last slash
 
It always seems to crash my repl
 
@Pavel 0/10 how can you not get it to work
 
6:31 AM
@ASCII-only It's a discord command not a sed command
 
@Pavel You're doing it wrong
@Pavel Didn't they remove it
 
@ASCII-only Sorry I meant skype command
 
Aug 26 at 4:05, by ASCII-only
@Pavel $m=self;def method_missing(n,*a)raise NoMethodError,''unless self==$m;a.length>0 ?n.to_s+' '+a[0].to_s: n.to_s;end
 
Lua, 175 bytes Try It Online!
 
@ATaco ^^ :P
 
6:33 AM
I don't know what that does.
I can't figure it out.
 
@Pavel >_> <_< >_> <_< It's a reply to one of your messages, if you forgot pls read transcript
 
Sets the the function that's called when a string is called to print its self and its arguments, then return the last argument it was passed, which is another string.
 
@ASCII-only I don't think I understood it back then either
method_missing is black magic as far as I'm concerned
 
This doesn't work because you can't assign attributes to str
 
@Challenger5 Yeah I'm getting a traceback on that
Oh nvm
 
6:36 AM
You'd expect it to be allowed since they were trying to eliminate the distinction between builtin classes and user-defined classes
 
Yeah C# doesn't let you overload operators for preexisting types either.
 
Delet black magic
 
@ASCII-only This bothers me even more knowing that ruby uses puts and not print
 
@Pavel Who said ruby doesn't have print
 
6:38 AM
I'm not saying it doesn't have print
I'm saying using print in ruby bothers me.
 
Yes
 
@Pavel Well I much prefer print over sys.stdout.write
 
I've been using $> <<
 
You've been using what O_O
 
6:40 AM
It even works if you subclass str and change that: Try it online!
@ASCII-only Shorthand to print.
 
$> is an alias to sys.stdout. Appending anything to sys.stdout writes it.
 
@Challenger5 better
 
Wut how can you do that
Subclassing is magical...
 
@ATaco Because preprocessor
 
6:41 AM
@ATaco :P
 
C's preprocessor is gr8
 
ikr
 
I can almost quine in it :P
 
Yep
As far as I can tell that would make you the first.
 
Shame I can't yet quine in it.
 
6:44 AM
@ASCII-only :P
 
@Challenger5 :P
 
@Challenger5 better
 
6:51 AM
cough Just read through that
 
 
1 hour later…
7:53 AM
wtf my internet connection is averaging 10kbps
 
8:05 AM
I'm now at 5 o_O
 
 
2 hours later…
@Lembik why did you delete your question?
 
@orlp I realised it was stupid
 
why?
 
or more accurately, that I was being stupid
what I really care about is a good lower bound not the exact value
 
@Lembik but I know the exact value
 
9:45 AM
oh!
is there a closed form ?
I will undelete if there is
and apologise
 
hey what's the question :c
 
@LeakyNun it was a math question
 
@Lembik tell me
(alt. undelete it)
 
I want a good lower bound for sum({3k choose 3i} for i from 1 to k)
 
well the original question was clearer
given 3k coins, what is the chance that the number of heads is divisible by 3?
 
9:48 AM
sum_{i=1}^{k} {3k choose 3i}
@orlp A much nicer formulation!
I wish I had asked that
 
and that's the answer
 
@orlp nice!
I mean, one can figure that out using binomial theorem
and cube roots of unity
 
what I did
 
right, that's your approach
 
no
 
9:50 AM
blimey
is that at least 1/3?
 
no clue
maybe it can be simplified
 
if it was at least 1/3 that would be cool
 
but consider a markov chain with 3 states
0, 1, and 2 mod 3
then after each coin we have 1/2 chance of staying in current state
1/2 chance of moving to the next one
giving transition matrix [[1/2,1/2,0],[0,1/2,1/2],[1/2,0,1/2]]
raise that to the power 3k and extract the topleft most coefficient to find your answer
you can find the closed form by diagonalizing the matrix
@Lembik and now the problem is in terms of matrices, so you should be happy :)
 
0.25
0.34375
0.33203125
0.33349609375
0.33331298828125
0.33333587646484375
0.33333301544189453
0.3333333730697632
0.3333333283662796
0.33333333395421505
0.3333333332557231
0.3333333333430346
0.3333333333321207
0.3333333333334849
0.3333333333333144
0.3333333333333357
0.33333333333333304
0.33333333333333337
0.3333333333333333
 
argh
so no nice lower bound
but it does at least tend to 1/3
 
9:54 AM
@Lembik define nice
 
lower bound is 1/4
sorry edited
 
I gave you an exact algebraic expression
:D
 
if the coin has 5 sides it's even worse :)
 
@Lembik but my method is generic :)
@LeakyNun my markov chain method gets those same numbers
 
@orlp nice
 
9:57 AM
you summed the binomials?
 
yes
should I use my method?
 
[1.0, 0.25, 0.34375, 0.33203125, 0.33349609375, 0.33331298828125, 0.33333587646484375, 0.33333301544189453, 0.33333337306976318, 0.3333333283662796]
[(M**(3*k))[(0,0)] for k in range(10)]
M = np.matrix([[.5,.5,0],[0,.5,.5],[.5,0,.5]])
 
can everyone here render $\text{this}$?
 
so 1/3 seems to be an upper bound
@LeakyNun no!
 
@LeakyNun I can with chatjax
 
9:58 AM
@Lembik it's not; see n=2
@Lembik go install ataco chatjax :P
 
@Lembik it oscillates around 1/3
 
hang on
 
@LeakyNun do you like my solution? :D
 
@orlp I don't really know much about Markov chains
 
@orlp hmm
I get
[sum(comb(3*k,3*i) for i in range(1,k+1))*(1/2)**(3*k) for k in range(1,
...: 10)]
Out[9]:
[0.125,
0.328125,
0.330078125,
0.333251953125,
0.333282470703125,
 
10:01 AM
but I get your method @orlp
I like your solution; you should try out mine :P
 
oh I see my mistake
 
@LeakyNun the crazy thing here is though
my method gives a closed form
so we have a closed form for that sum
is that closed form new? it's very nontrivial
 
@orlp binomial theorem and cube root of unity can also provide that closed form
 
[sum(comb(3*k,3*i) for i in range(0,k+1))*(1/2)**(3*k) for k in range(1
...: ,10)]
Out[10]:
[0.25,
0.34375,
0.33203125,
0.33349609375,
0.33331298828125,
0.33333587646484375,
 
by extension we have a closed form for $\displaystyle \sum_{i=0}^{k+1} \dbinom{nk}{ni}$
 
10:04 AM
@LeakyNun interestingly wolframalpha doesn't know it
 
@orlp wolframalpha knows shit
@orlp you should use polar form to cancel out the imaginary parts
my lord
 
@LeakyNun I can't really be bothered tbh :P
 
@LeakyNun doesn't give it for me
oh now it did
@LeakyNun well, there we go :)
I bet that $8$ is really $2^3$
 
so the prob gets arbitrarily close to 1/3 it seems
 
10:07 AM
@orlp sure
 
but oscillates around it
 
@LeakyNun this can't be right
 
sorry, to k
 
this grows without bound
look at the 8^k term
 
@orlp we haven't divided it by 8^k
 
10:08 AM
what is there to cancel it?
ah
 
$\displaystyle \sum_{i=0}^{3k} \dbinom{3k}{i} = (1+1)^{3k} = 8^k$
lmao I linked to k and wrote k+1
 
if I wanted to I would've eventually reached that form by simplifying the monster I got
.... eventually
 
right
are you familiar with complex numbers esp polar form?
 
@LeakyNun familiar-ish
 
@orlp then what is $(1-i\sqrt3)$?
 
10:11 AM
eh which angle had sqrt 3 as sine again
2sin(pi/3)
so
 
are you typing?
 
thinking
wait I'm doing this horribly inefficiently though
 
use argand diagram boi
 
oh the sum has a closed form
 
never heard of that
 
10:15 AM
I mean a nice real closed form :)
 
I know that r = 2
 
$\sum_{j=1}^k\binom{3k}{3j}=\frac13\left(2^{3k}+2(-1)^k\right)-1$
 
because 1^2 + sqrt(3)^2 = 4
 
@orlp it's where you plot a number using the horizontal axis as the real axis and the vertical axis as the imaginary axis, and then read of its polar form by pretending that you're using the polar coordinates
@Lembik right
 
@LeakyNun did you already know that?
 
10:16 AM
@Lembik I don't, but I have an approach ready
if I did it then I would figure it out
 
cool
the proof is
$$
\begin{align}
\sum_{j=0}^k\binom{3k}{3j}
&=\frac13\left(\sum_{j=0}^{3k}\binom{3k}{j}+\sum_{j=0}^{3k}\binom{3k}{j}e^{2\pi ij/3}+\sum_{j=0}^{3k}\binom{3k}{j}e^{-2\pi ij/3}\right)\\
&=\frac13\left(2^{3k}+\left(\frac12+i\frac{\sqrt3}2\right)^{3k}+\left(\frac12-i\frac{\sqrt3}2\right)^{3k}\right)\\[3pt]
&=\frac13\left(2^{3k}+2(-1)^k\right)
\end{align}
$$
 
nice
 
not solved by me sadly
but nice :)
 
essentially the same as my giant monster though
although written a lot nicer :)
 
I assume this generalises from 3k to ck
 
10:19 AM
@LeakyNun $2e^{\frac{5}{3}\pi i}$
 
@orlp so what is its cube?
@Lembik now?
 
$8e^{\pi i} = -8$
 
simplified?
good
 
@LeakyNun this is a pretty nice example of a problem that's hard to solve without complex numbers
even though neither the problem nor the final solution uses them
 
right
 
10:28 AM
@LeakyNun I've used this "problem -> transition matrix -> diagonalize -> closed form" setup before
7
A: finding an explicit formula for a two variable recursion

orlpIf $f_{k, n}(x)$ for each $1 \leq x \leq n$ forms a vector $\vec{f_{k, n}}$ of probalities, then: $$\vec{f_{k+1, n}} = \begin{bmatrix} 1 & 1\over 2 & 1\over 3 & \cdots & 1\over n \\ 0 & 1\over 2 & 1\over 3 & \cdots & 1\over n \\ 0 & 0 & 1\over 3 & \cdots & 1\over n \\ \vdots &\vdots &\vdots &...

I have no idea how I would solve it otherwise
 
I see
 
PPCG people are rocking math.se I see :)
 
@Lembik not really, at least not me
 
:)
 
I like math and I have a bright idea from time to time
but there are tons of people that are infinitely smarter than me on that website
at least in math
especially mathoverflow
I don't even understand the question there the vast majority of the time
 
10:36 AM
MO is a complete mystery to me too
and I assume almost everyone else too :)
 
@LeakyNun you know that NAND is functionally complete, right?
and so is NOR
how many functionally complete 3-ary gates are there?
 
@orlp no i dea
 
and how many functionally complete n-ary gates
 
11:13 AM
I count 6 of the 16 2-ary gates as being functionally complete
although two of those are simply reversed inputs of the other two
 
11:57 AM
1
Q: Linking to the sandbox

Bruce ForteWhy do people keep posting a link to the sandbox below their question? Isn't the sandbox supposed to serve the OP as a way of getting feedback on a challenge? It seems like a lot of people are mistaking (or am I?) the purpose of the sandbox as a golden ticket to success. Is there an unspoken rule...

 
12:23 PM
@Downgoat hey I finished my essay @ATaco
 
12:53 PM
@Downgoat Did you read? (also why nobody on?)
 
you don't need to ping multiple times...
he's probably just not here yet
 
He came in the room. And someone got on the essay (several people in fact) then he left the room and everyone left the essay
I just wanted to see if he read it (he helped me write it)
 

« first day (2431 days earlier)      last day (2422 days later) »