« first day (3328 days earlier)      last day (1624 days later) » 

12:45 AM
Anyone knows how to implement a user defined function?
 
mr5
Action userDefinedAction = () => { };
 
Alright, sorry and my bad for not providing much context (coding in C). so far I am trying to implement a user defined function in a simple calculator. I am using void read_number {}
 
mr5
okay, so you want something similar in C language?
 
include <stdio.h>
// User define function

/*
Declaration
Defination
Calling
*/

void read_number1();
void read_number2();
int main()
{
int count1=0, value=0, number1=0, number2=0, operation=0;
printf("Enter the first operand, one digit at a time ... or enter -1 to stop \n");
scanf("%d", &value);
while(value != -1)
{
number1=number1*10+value; // new digit is added to the existing operand
count1+=1;
printf("Enter the next digit of first number or 0-1 to stop ...\n");
scanf("%d", &value);
}
printf("the first operand = %d \n",number1);
thats what my code looks like
im also trying to global variables
use*
 
mr5
What do you mean by "user defined functions"?
I see no correlation in your code.
 
 
3 hours later…
3:46 AM
!~>class A{
static object Main(){ return Generate() == Generate(); }
static string Generate(){
    var r = new Random();
    var c = new List<char>();
    while (c.Count<9){c.Add((char)r.Next(20000,90000));}
    return new string(c.ToArray());
}
}
@nyconing True
@nyconing True
is Random generates random using pi?
 
 
4 hours later…
7:36 AM
Morning
@nyconing Unlikely, Pi is a constant, but has limited size AFAIK
It wouldn't be more random than not using it, and using a random seed and system variables that change very fast
It would make sense if you could store infinite Pi decimals
 
Pi isn't random
 
2 mins ago, by Héctor Álvarez
@nyconing Unlikely, Pi is a constant, but has limited size AFAIK
 
I mean it seemingly is, but to be strictly random, it would have to be able to repeat
 
Yeah but the decimals are supposed to contain any number
because the decimals in Pi always change and are different
 
however improbable, you could in theory ask for a thousand random numbers and have them all be 0
 
7:40 AM
e.g. you can theoretically find your own phone number if you search deep enough
 
and you could keep on asking for another random number and it would return 0
whereas PI cannot repeat
 
I believe it can
 
If it could repeat the digit 0 indefinitely, then it would basically end and therefore be rational
 
but later on
no
it's not "infinite zeroes"
stop creating a paradox
this is not Terminator
 
ok, well if you ask for a random number, there is always a possibility that it will be a 0
Pi cannot have this probability, because it would end
 
mr5
7:42 AM
Jack, give me random
 
I assume it would be possible to find any number
 
mr5
Jac, random
 
say a number from 1 to 100 digits
 
mr5
Jack, random
 
7:42 AM
....Come Again?
 
!~>Math.Random;
 
mr5
@CaptainSquirrel no random!?! this is unforgiveable!
 
@HéctorÁlvarez 'Math' does not contain a definition for 'Random'
 
you can't find any number
 
@HéctorÁlvarez Math.Random;
 
7:43 AM
that's the point. Can you find 333333333333333333333333333333333... in the digits of pi?
 
mr5
!~>new System.Random().Next(1, 100)
 
@mr5 54
 
that's a number that exists
and yet if you found it in pi, pi would be rational
 
mr5
!~>new System.Random().Next(1, 99+1)
 
@Neil I think so, theoretically any finite number will appear at some point
 
7:44 AM
@mr5 16
 
Oh you're right
 
@HéctorÁlvarez ah, there's the keyword :P
any finite number can be found, but not any number
 
Right
This is all from my shallow understanding of Pi because I don't really have a PhD in math
 
interestingly, though you could find any number in the digits of pi, the longer the number, the bigger the number indicating its position in the digits of pi most likely
so that yes, you could represent all of shakespeare's works in the digits of pi to one position, but that position index would be much much much bigger by comparison
at least statistically
if you're looking for 1415926, then it's position 0
 
After all how is Pi calculated
I know the perimeter is 2 Pi r
 
7:48 AM
Morning all
 
there's a very efficient algorithm that lets you calculate from any starting position
@Mathematics speak of the devil
 
So Pi = Perimeter / 2r
It sounds surreal
 
@Neil lol
 
@HéctorÁlvarez what's surreal to me is euler's identity
 
generated a httpclient using NSwag, usually its happy with .Result as shown below

var results = myHttpClient.GetAsync().Result;

but now I am getting

Task' does not contain a definition for 'Result' and no accessible extension method 'Result' accepting a first argument of type 'Task' could be found (are you missing a using directive or an assembly reference?)
 
7:50 AM
it feels a bit like magic to me
 
problem is why it would work in some solutions and not in others :/
 
mr5
I would never want to touch the .Result property of Task
 
why not
 
@Neil I still don't know why that equation would be true
 
well i won't touch NSwag proxies as well but i have to lol
 
7:52 AM
@mr5 so you always touch it? :)
 
@HéctorÁlvarez me neither
 
@Mathematics it's because a Task doesn't have a .Result. a Task<T> does
 
mr5
@Default haa! got me :D
 
hehe
 
@Default ahhhhhhhhhhhhhhhhh, studio nSwag to blame
 
mr5
7:53 AM
wtf is NSwag?
 
@mr5 Exactly... it's a proxy generator
 
mr5
it looks like a type generated by douche. jk :)
what do you think of the syntax?
looks complex, no?
 
no
 
mr5
I wish the 2nd generic type is inferred
 
GetUsersCommnand with a DataRespond with contains list of user
it looks fine to me
 
7:57 AM
You could box the first generic to a UsersResponse and it would (perhaps) look more clear.
so a Query takes a Response and a Command - I think that looks quite clear
 
mr5
well, this is event-sourcing, which indirectly invoking a method from AccountService
 
@mr5 you mean you type one but C# infers the other?
 
mr5
if I have to directly invoke the method from that service, it would be as simple as the above ^
@Default yeah
EventSourcing#Query<TOutput, TInput>(TInput input)
 
is TOutput the return value?
 
mr5
This is how it looks. I am thinking I could just drop the TInput and change the type to object
yes
 
8:02 AM
then it should be able to infer that as well, as long as you explicitly type the classname, no? 🤔
 
mr5
unfortunately no.
1
Q: Infer generic type with two generic type parameters

Thomas FlinkowI have the following method public bool HasTypeAttribute<TAttribute, TType>(TType obj) { return typeof(TType).GetCustomAttribute<TAttribute>() != null; } and I want to be able to use it like this: MyClass instance = new MyClass(); TypeHelper.HasTypeAttribute<SerializableAttribute>(instan...

 
@mr5 what's before the = await?
 
mr5
it's just assignment
var users = await ...
 
change var to DataResponse<List<User>> and it should work
 
mr5
nope
 
8:13 AM
GoOoOoOoOoOoOoOoOoOoOoOd Mornin' pleberinos!
 
Goood moorniiiiing CeeeeShaaaaarp! How've you all been?
 
@Default why wouldn't var work?
 
8:29 AM
@Squirrelkiller you late boi
Also don't forget to gratulate the Rickl0rd today
My german tourette just broke out.
I was scanning the star board and instead of "hell" I read "heil".

Oh silly me!
 
@mr5 yep, that looks like way too much noise
var mr5 = User.find { Users.name eq "mr5" }.single()
 
@Squirrelkiller Where have you been hiding?
 
this is what I use now...
not as nice as what I used to use, but I cant use what I used to use any more
what I used to use is var mr5 = userRepository.findUserByName("mr5")
 
ahoy mateys o/
@mr5 not gunna lie, i've not touched the bot since last week sooooo
 
8:48 AM
is there a dictionary available with index?
 
Why
That defeats the purpose of the dictionary
hash list?
 
because I needed to iterate the keys
and then add values to them
 
Use an array then
 
but I need to find the corresponding key
based on a given value
 
!~>new Dictionary<string, string>{{"a","foo"},{"b","boo"}}.Values.ElementAt(1)
@nyconing boo
 
8:50 AM
is order preserved in a dictionary?
if it's purely implemented by a hash set then no
 
@Squirrelintraining Don't worry, got my xing notification too :D
 
so which ds to use?
 
"Dictionary with index" is to "array" as "GIF with sound" is to "video clip"
 
@Shad SortedDictionary would be my guess
 
mr5
@Wietlol :'( I'm virtually single though :'(
 
8:55 AM
@HéctorÁlvarez But I need the key if a given value matches
 
!~>()=>{
var keys = new Dictionary<string, string> {{"a", "foo"}, {"b", "boo"}}.Keys.ToList();
return string.Join(",",keys);
}
@nyconing Argument 1: cannot convert from 'char' to 'string'
 
@mr5 there is a single person named "mr5"
 
mr5
@Wietlol is repository a wrapper for both local copy and server side copy?
 
and if there isnt, I get an exception
@mr5 you mean for an in-memory database and a server database? yes
 
@nyconing a,b
 
8:55 AM
@Shad So... you want to retrieve keys after looking up values?
 
yea
 
mr5
@Wietlol what I mean by single is status in relationship though
 
I think you have a conceptual misunderstanding
Jack, xy
 
....Come Again?
 
8:56 AM
let me explain
 
> The order of the keys in the Dictionary<TKey,TValue>.KeyCollection is unspecified, but it is the same order as the associated values in the Dictionary<TKey,TValue>.ValueCollection returned by the Values property.
 
mr5
@Wietlol so what do you recommend to lessen the absurdity of this syntax?
 
not C#?
 
8 mins ago, by Shad
because I needed to iterate the keys
 
you could ofcourse hide that absurdity in a place where the sun doesnt shine
 
8:57 AM
in order though
 
mr5
eh not possible atm wiet
no budget for that
 
Keys - A B C

for A -> 1,2,3

for B -> 4,5

for C -> 6,7
 
hiding it doesnt require any budget
 
Now when I see a value 3

I would like to get the corresponding key!
that is A
 
@HéctorÁlvarez if you explicitly type it then C# can infer it
 
8:58 AM
that is why though of Dictionary
 
@Shad if you need it to work both directions, have two Dictionaries
so another dictionary with 3 -> A
 
Dictionary<char, List<int>>
 
in the repository version, I only declare the interface like this:
interface UserRepository : JpaRepository<User, Long>
{
    fun findUserByName(name: String): User?
}
 
@Default var's task is to infer the type correctly, which the compiler should be able to just fine.
 
but it demands a specific dependency container
and I cannot use that
 
8:59 AM
:o
 
my current approach is to still use those interfaces, but provide the implementation of them with the library of my choosing
 
'A', 'B' ,'C' are fixed
 
(the implementation was generated in the first case)
the sql library I use can be horrific, but noone would know
 
@Shad Think again, what you want to do is look up a definition and find the word for it. Pick up the nearest dictionary and look up "a thing consisting of a number of different and distinct parts or items that are grouped together." and then grab the word that references this data.
In short, that's not how a dictionary works
 
so you are telling me
 
9:02 AM
!~>()=>{
var dict = new Dictionary<char, List<int>> {{'A', new List<int>{1,2,3}},{'B',new List<int>{4,5}},{'C',new List<int>{6,7}} };
return dict.First(x=>x.Value.Contains(3)).Key;
}
@nyconing A
 
1 -> A
2 -> A
3 -> A
4 -> B...
 
@Shad Correct. Dictionary keys are unique, values are not.
 
I was first thinking of Tree
 
Because values are not unique, you can't get the key from the value.
 
hmm
 
9:03 AM
You can do something like @nyconing did, and return the first key that matches, if that's what you want.
 
or you can use a double dictionary
 
yes that would do
 
@MadaraUchiha sure you can. You would simply get the same key for different values
 
but that thinking is wrong?
 
a BiDictionary
I assume
 
9:05 AM
@Wietlol If that's what you're into, hey, I totally respect that
 
assuming that you can guarantee that the values should be unique
 
mr5
@Wietlol HomoDictionary?
 
@Wietlol Are you assuming its gender?
 
Why nyconing code works? If that is wrong thinking in the first place
 
> Alternatively, you can use a Bi-Directional map like Guava provides
(java tho)
 
9:06 AM
I mean why is that available then
 
> BiMap<Character, String> myBiMap = HashBiMap.create();
 
mr5
and that requires you to switch language
 
@mr5 but you can copy it to C#
assuming none already exists
140
A: Getting multiple keys of specified value of a generic Dictionary?

Jon SkeetOkay, here's the multiple bidirectional version: using System; using System.Collections.Generic; using System.Text; class BiDictionary<TFirst, TSecond> { IDictionary<TFirst, IList<TSecond>> firstToSecond = new Dictionary<TFirst, IList<TSecond>>(); IDictionary<TSecond, IList<TFirst>> sec...

 
Good: Build second dictionary reversing values into keys and keys into values. Better: Build second dictionary when you build the first. Bad: Perform reverse key lookup each and every time you require to know a value's key.
 
@Shad go with whatever you think it's right, seems like you've got your mind set on it anyway. But don't ask us when the person that has to maintain that calls your mother names.
 
9:08 AM
Martha!
 
:' (
 
what happens when you write:
 
Nothing, apparently.
 
using (var stream = new SomeStream())
    return stream;
 
@Shad it worked because C# is a highly customized language. it was not a good approach because you defeat the purpose of Dictionary, and iterate trough may cause performance issue
 
9:09 AM
ew
 
Oh you hadn't written it yet, sneaky.
 
that will return a closed stream
 
delete your post after it
can the caller of the function use that stream?
 
@ntohl You return the stream, and because you return, the instance will be reclaimed by GC anyway so it's kinda pointless anyway
 
@HéctorÁlvarez it will not be reclaimed by the GC
 
9:11 AM
But you bring up a good question.
 
only when it has lost all references to it
 
@HéctorÁlvarez because of the using, or because of the returning from a function? Because latter is not true. How would a factory work?
 
but the stream is still closed, so you cant read from it
 
thank you
 
@ntohl since it is closed, not really no
 
9:12 AM
@Shad I was here to answer your question, and provides code that correct, according to your question... but as others said, it was not a good approach. But if your dictionary is not so big, or performance isnt an issue, then it was fine, dont think too much
 
no I will reverse it
 
@Wietlol so using does it's magic at the end of function block?
 
yep
using is short for
 
hugs
 
9:13 AM
var stream = new Stream();
try {
    return stream;
}
finally {
    stream.Dispose();
}
 
all using does is dispose the object instance at the end.
 
if you return the stream, the finally block still gets called
 
it's short for
 
C#8 : using var foo = new Bar();
 
from now on I will post by every code in code review so
 
9:13 AM
hehe :D fixed it
I am too used to Java :D
 
using var it will dispose after statement ends
use using var because it does not creates another code block
 
using var will dispose it lazily tho, no?
or did that change since the preview?
 
@Wietlol (¬‿¬)
 
ohh. I very much like that it's visible what is the lifecycle of the disposable
 
but close is smaller than dispose
 
9:15 AM
I don't like using var
 
just like ext method
some doesnt like it
 
ext method?
 
mr5
ext is short for what? exit?
 
ention
 
ention methods
ah, why didnt you say so?
 
9:17 AM
@Wietlol exactly
 
tention methods
 
Ent ions. Like walking sapplings
 
lets announce ext method and ention method at C#9.0
 
mr5
@Wietlol extention?
you mean, extension?
 
How can you tell if someone is a construction worker or a chemist? Ask them to pronounce unionized
 
9:18 AM
burárum
 
un ion ni zed
 
un i on iz ed
 
mr5
unyon-zed
 
annyeonghaseyo
 
I usually pronounce it as unionized
 
9:19 AM
onion ized
^ or a chef
 
good morning
 
Burárum
so glad there is á on my keyboard
 
ohai avner
 
why there is á on your keyboard
 
same because there is ű too
 
9:22 AM
I have ' on my keyboard and a on my keyboard
 
hungarian keyboard
 
I can write á easily
 
ā
 
and à and â and ä and ã and all the others
 
ΘΘ
my special keys are: öüóőúéáűí
 
9:22 AM
I dont have those on my keyboard, but I can type it by 'v8d'
 
á and à are pretty common in my language tho
 
mr5
what does "ohai" means?
 
and for some characters also the umlaut ë
 
Interjection: ohai
  1. (uncommon, Internet slang) oh hi (a purposeful misspelling)
I did not write this wikipedia article
 
9:24 AM
purposeful misspelling
 
@Wietlol 10/10 disclaimer.
I thought ohai was short of ohayu gozaimas
 
ohayou
 
I think it's derived from the original cheezburger cat memes.
 
@Proxy ohayou
 
I should also say "obai"
 
9:27 AM
@nyconing No, that's if you want to write it correctly in Romanji
also gozaimasu
But you never say the U
 
hi
can i ask questin
 
a quest in?
 
@AvnerShahar-Kashtan now I'm hungry :(
 
a question
 
@LPGTESOFTS I don't know, can you?
Jack, welcome LPGTE
 
9:28 AM
@Wietlol no, the complement to oh hai is kthkbye.
 
....Come Again?
 
hahahaha
funny jack
 
thanks
 
@LPGTESOFTS Always feel free to ask directly. You don't need to ask if you can ask. If you ask if you can ask you're already asking so you might as well ask.
 
lucky he doesnt responds "Is that even English?"
 
9:30 AM
HAI IM IN UR PCZ
KTHXBYE
 
I answer question here and search to start working in open source or freelance, any idea ?
 
@Neil a cat on your keyboard?
 
nah, when my cat types, it's more like piojpiojruereerqq
I do have two cats, and for whatever reason, one really likes to walk in front of my computer screen and stare at me
I think he wants to sit on my lap, but he never makes the first move
which is particularly aggravating when I'm in the middle of a game
 
@LPGTESOFTS What's the question exactly?
 
the question is ask about the idea
 
9:33 AM
want to start open source project or freelance, any orientation ?
 
any swagger guru in here ?
 
mr5
GitHub now has bounty feature per task. Maybe you can consider that as freelance job? @LPGTESOFTS
 
maybe.. start at stackoverflow.com/jobs
@Neil I have a cat but I prohibit she being on my desk
because she dropping random objects on my desk, and play it on the ground
you know, if you have time, you can build some app on mobile phone
 
@Wietlol Correct, but I do believe you wrote the wiktionary entry for it
 
no :D
 
9:41 AM
If HttpContent.ReadAsAsync fails, does it throw or return null?
 
mr5
 
GitHub does contain Freelance mission ?
 
mr5
 
Why?
It's 18 lines isntead of 1
 
mr5
oops wrong function
well, you can leverage the auto transformation in case you already know the type returned by your web service
var fashionModel = await JsonDeserialize<FashionModel>(response).ConfigureAwait(false);
fashionModel.FirstName = "Wietlol"
 
9:52 AM
@nyconing ohayou
more or less
 
I am fashion?
that is new
 

« first day (3328 days earlier)      last day (1624 days later) »