« first day (208 days earlier)      last day (2058 days later) » 

12:00 PM
Well it ends for this case but not for my case
 
y is basically "find first n outputs"
InputArgs:N:Pred y .
 
Oh, thanks
 
you often use it for things like "given n, return the nth element of that series"
you use y then take the last element
 
What witchcraft
It worked, thanks
?
 
what should it do?
 
12:07 PM
remove the b&2 to see
 
b&2.
very dubious part
 
b2& also doesnt work
 
what do you want to do after the findall?
 
behead
 
and then?
 
12:08 PM
then call pred2
 
@Fatalize j'suis la personne le plus stupide
pou ajouter le point
@Fatalize quoi
 
12:25 PM
y returns a list
take the last element to get a string and not a list of 1 string
 
thanks
so you can post it xd
 
go for it
 
ok thanks
0
A: Alphabet triangle

Leaky NunBrachylog, 37 bytes @A:1fb:2&~@nw ~c[A:B],A:1:2yt. :Lc.r. Try it online!

@Fatalize Problem 1 would be much harder in Prolog
 
last element?
 
12:40 PM
Yep
But, I'm not going deep into Prolog
just Brachylog is enough for now
 
wouldn't be that hard though
reverse and take the first
or recurse until one element
 
oh, you can reverse?
I thought Prolog is pretty much lifeless
by life I mean built-in
 
@Fatalize I see
 
but this is partly why I created Brachylog
reverse only works on lists
working with types in Prolog is pretty annoying
 
12:50 PM
Built my explanation
@Fatalize Earlier you said f can be used as checkall
I don't get it
How do I assert that all elements satisfy predicate 1?
 
:1a does that
but
you can do the same usually with :1f
if you start your predicate 1 with "take an element from the input"
e.g. with e or :Im
actually
then you would need to check that the result of findall has the same length as the input
and that there are as many choice points in pred 1 as elements in the input
so yeah use a :p
 
What.
@Fatalize What am I missing again?
Yep, I missed the point again.
 
1:09 PM
you're trying the Eliminate consecutive duplicates of list elements. right?
 
Yes
Done
Pretty sure the official solution uses recursion
 
Wait, what the hell?
 
1:11 PM
LOL
I forgot somehow
 
:p
Let me peek at your solution...
brachylog_string_blocks([],[]).
brachylog_string_blocks([H|T],Blocks) :-
    brachylog_string_blocks([H|T],H,Blocks).
brachylog_string_blocks('string':[H|T],StringBlocks) :-
    maplist(prepend_string,Blocks,StringBlocks),
    brachylog_string_blocks([H|T],H,Blocks),
!.
 
(my prolog code is sometimes more complicated than what's needed in the problem because it needs to work multiple ways)
 
Sure
 
I don't get your prolog code
Basically the useful part is this
brachylog_string_blocks([H|T],Blocks) :-
    brachylog_string_blocks([H|T],H,Blocks).
When did you go from a dyad to a triad
 
1:15 PM
you're missing a whole part of the code
those rules are only here to set up things depending on the type
 
brachylog_string_blocks([],_,[[]]).
brachylog_string_blocks([H|T],H,[[H|T2]|T3]) :-
    brachylog_string_blocks(T,H,[T2|T3]).
brachylog_string_blocks([H|T],I,[[],[H|T2]|T3]) :-
    dif(H,I),
brachylog_string_blocks(T,H,[T2|T3]).
 
below there's the code
 
Oh, right
 
with 3 args
 
I'm the stupidest person ever
 
1:16 PM
Most likely not :p
 
Most likely so
Never mind, I'll stop looking at the code
Try to golf this without the built-in
And without changing :1:1y to :1f because time
 
This is pretty slow though
 
Why is your @b so slow
Z = ["aaaa","b","cc","aa","d","eeee"]
real	0m3.043s
user	0m0.415s
sys	0m0.017s
Get a better algorithm
It should be O(n) time
 
1:22 PM
It shouldn't be this slow, I'll look why
 
How to map individual char in strings
Never mind, even this is slow
Must be someone depleting resource again
Z = ["abccd","abccd"]
real	0m4.806s
user	0m0.439s
sys	0m0.029s
 
Yeah
just tried on my pc @b it's fast
 
:?zcc. P14 KO
 
?- time(run_from_atom('@b.',"aaaaaaaaaaaaaabbbbbbbbbbabbbbbbbbbbbaaaaaaaaaaaaaabbbbbbbbbbbababbbbbbbccbbac",Z)).
% 7,361 inferences, 0.000 CPU in 0.007 seconds (0% CPU, Infinite Lips)
Z = ["aaaaaaaaaaaaaa", "bbbbbbbbbb", "a", "bbbbbbbbbbb", "aaaaaaaaaaaaaa", "bbbbbbbbbbb", "a", "b", "a", "bbbbbbb", "cc", "bb", "a", "c"].
so that's a TIO's problem
 
@Fatalize yep, I also think so
 
1:25 PM
@LeakyNun For now you have to split the string into a list of chars, I really need to make it so that a works on strings though
and integers for that matter
 
@Fatalize how?
 
:ef
 
Oh, right
Very useful
You have dichotomize up to ennachotomize
but no n-chotomize
 
yeah I know lol
 
Alright
 
1:27 PM
the funniest is
in the code, dichotomize to enneachotomize call n-chotomize with a list of fixed length as output
 
...
 
so it would be easy as hell to add n-chotomize, I just forgot to
 
you win
 
...
 
1:30 PM
tbf the problem I would have is how do I specify the N
I could do [Thing:N] as input
or I could do Thing as input and use the length of the output as N
 
You know
 
so say you want to split @A in 13 and @1 is n-chotomize, it would either be @A@1.l13 or @A:13@1.
 
Prolog is like a child
You can't directly tell him the solution
But you can't leave the search space too big either
And that's what I enjoy about it.
 
Ideally you wouldn't care about the search space in a declarative language
but obviously in real life you can't always ignore it
 
That is if you have the time to teach him
How does things like .r. actually work?
 
1:35 PM
what do you mean by actually?
 
Like
How do you identify this pattern
And then assign the search space
Because we all know that Prolog is not an actual child
 
@Fatalize I don't think that answers my question
By the way, link in chatroom description?
 
If you want to know how Prolog matches things, then you would need to read something like this
and then I won't be of much help :p
 
Alright
What the actual putain?
 
1:40 PM
room topic changed to Brachylog: Discussions about the Brachylog language. github.com/JCumin/Brachylog (no tags)
 
TIO link?
 
room topic changed to Brachylog: Discussions about the Brachylog language. github.com/JCumin/Brachylog . Try it online! brachylog.tryitonline.net (no tags)
 
Thanks
 
@LeakyNun There is an infinite number of possible true answers to that predicate
predicate 1 that is
 
Sure, but
why on earth would it go in that direction
 
1:43 PM
because of the implementation, that's all
 
Alright
That wasn't an actual question, lol
 
Oh I know where this comes from actually
it's a printing bug more than anything
 
Actually, how do you check that every item in an array is equal
or that every item in an array is equal to a certain thing
which is really the same
 
the predicate really returns "abc" + free characters + "cba"
but the predicate that prints the results doesn't know how to print free characters
so it prints quotes instead
@LeakyNun dl1
 
I see
@Fatalize Genius
 
1:48 PM
if you want to check that say the element is 0 then d[0]
 
Oh, thanks
@Fatalize What the hell
 
what?
 
@Fatalize When does : append and when does : concatenate...
 
it appends when it's after a builtin and concatenates after a variable
I think
 
Oh, thanks
Eh, nope.
Change {l.} to l and it works
while the two should be the same
 
Oh, merde
 
but {} means that the second line is now the second predicate
not the first :p
 
j'suis la personne le plus stupide dans le monde entier
 
I got tricked by this a few times too
This does what you wanted
though probably golfable
nevermind
this actually doesn't work
 
@Fatalize whatever
P16 KO
@Fatalize
That is still too imperative though
P17 is better h~c[A:B],?t~lA,[A:B].
 
2:16 PM
and it doesn't seem to work when you have more than one element to drop
 
@Fatalize ?
 
should drop c f and i
if I understood the problem correctly
 
@Fatalize Please, don't give a string so long
It takes time
How do I do conditional?
 
^ more declarative
and much faster too
 
What sorcery is this
 
2:20 PM
I don't know why you didn't do this it's the simplest approach
"find all chars whose index in the string are not a multiple of 3"
basically
@LeakyNun What do you mean?
 
@Fatalize je te dis pourquoi
Parce que:
21 mins ago, by Leaky Nun
j'suis la personne le plus stupide dans le monde entier
@Fatalize if A do B else C
 
A,B;C
 
alright
 
don't need the comma if things chain together obviously
 
As you see, I need time to go into declarative mindset
and how is () used?
What is the default precedence?
 
2:23 PM
What do you mean
 
What is the default precedence if I don't use ()
from left to right?
 
() is just used to group things you want to be true together
 
then what is the default?
left to right no matter operator?
 
everything is left to right
 
I see
 
2:26 PM
(hX;?tX)w
if you findall on this it will print the first then the last element
 
I don't get the strcture
 
(
    X is the head of ?
Or
    X is the tail of ?
)
write X
 
How do you add K to each argument
 
here I could do just hw;?tw but say you have something much longer than just w you wouldn't want to write twice the same thing
@LeakyNun list of ints, add K to each int?
 
@Fatalize yes
@Fatalize so basically implicit findall
 
2:29 PM
no
it doesn't findall
it takes the left one firts
if later in the code it gets false then it will come back here and take the second value for X
 
@Fatalize where is K?
 
Wait... when did z vectorize
 
zip works until the longest element is depleted
?h is [1:2:3:4] and K is [3]
 
I see
 
2:34 PM
if you put 3 instead of [3] it will use the digits
so it will work for 1 digit numbers but not bigger numbers
 
damn
 
Usually the shortest solution is the one that reads like the problem
"Find all chars with index between I and J"
 
Alright
 
2:39 PM
19 is fairly easy
 
@Fatalize I wanted to use $( but then negative
 
Right, so I outgolfed you with your assistance
not cool
 
2:46 PM
There is a bug in the parser where when you put builtin names in square brackets it doesn't parse properly
 
but really, is there no way to append a builtin
So i is practically impossible
 
it's pretty bad at the moment I'll give you that
 
alright
You should really add an append builtin asap
?- append([H|T],A,R):
  R=[H|T|A]
(completely useless Prolog code because I don't speak Prolog)
 
assuming 0-indexing
 
I don't care
 
2:52 PM
P25 (*) Generate a random permutation of the elements of a list.
No random right now so RIP
 
same as before
you can't put the = directly after the h<=. because at that point it has no upper bound so it would generate an infinite amount of choice points
I have to go, not sure I'll be back later
Bye
 
Yep I just discovered a good trick
Instead of doing tT,?hs.lT
You can do this
(P26)
 
 
1 hour later…
4:27 PM
@VTCAKAVSMoACE Welcome
 
@TùxCräftîñg Welcome
 
@TùxCräftîñg In the mainstream languages, you give commands to the program
In Prolog derived languages however, you state the problem and the computer finds the solution
@TùxCräftîñg You can see an example here
Where declarative-style syntax outgolfs imperative-style syntax
 
5:05 PM
Still O(n)
 
5:19 PM
4 people here wtf
 
@Fatalize I had done some advertisement
(2n)!/(n!(n+1)!)
Can be shorter?
 
$! is factorial
 
oh right
Only 2 bytes saved
 
Brachylog is pretty terrible for formulas
 
Then let's find a way to do this declaratively
> Number of ways to insert n pairs of parentheses in a word of n+1 letters.
@Fatalize Partitions?
Namely: 3 returns [[3],[2,1],[1,2],[1,1,1]]
 
5:33 PM
for integers or in general?
 
Integers only
Strings are quite easy
Oh, I'm stupid
-y:{~c.:la*'0}f:{:la.}a.
Why do we keep writing :1f to confuse ourselves when inline predicates have the exact same byte-count?
 
Just a matter of preference
 
Alright
Can you golf it further?
 
I'm not even quite sur why this works
 
@Fatalize uh, convert to list to prevent indefinite backtracking
@Fatalize How do I say (pred and pred) or (pred and pred)?
 
5:50 PM
(pred,pred;pred,pred)
 
so the ands are grouped together
 
yes
 
Also, if I do pred1 and pred2 and pred3 or pred4
the variable declared in pred1 is lost in pred4
 
yes
 
where what I really want to do is pred1 and (pred2 then pred3 else pred4)
 
5:52 PM
pred1(pred2,pred3;pred4)
 
what...
brb golfing
btw atoi?
 
string to int?
 
yes
 
none as of yet, shortest I found is take the index of the char in the string "0123456789"
:p
 
mine too
0
A: Reduce and generalize a list of string

Leaky NunBrachylog, 61 bytes :{:ef:{~s"0123456789","X".;?.}ac.}a:{rbh"/",?rbr:"Y"c.;?.}ad. Try it online!

 
oh, nice
0
A: Reduce and generalize a list of string

Leaky NunBrachylog, 61 59 44 bytes 2 bytes thanks to Fatalize. :{:ef:{~s"0123456789","X".;?.}ac.}a:{rbh"/",?rbr:"Y"c.;?.}ad. :{:ef:{~s"0123456789","X".;?.}ac.L(rbh"/",Lrbr:"Y"c.;.)}ad. :{s"/",?rbbbr:"X/Y"c.;.?t~s@A;?rbr:"X"c.}ad. Try it online!

Used better pattern detecting
@Fatalize Can we check if a number is Fibonacci?
 

« first day (208 days earlier)      last day (2058 days later) »