comma

Haskell tuple constructor (GHC) and the separation between a language and its implementation

我与影子孤独终老i 提交于 2019-12-02 19:58:54
Haskell blew my mind yet again when I realised that (x,y) Is just syntactic sugar for (,) x y Naturally I wanted to extend this to larger tuples. But (,) x ((,) y z) Gave me (x,(y,z)) Which was not what I was looking for. On a whim, I tried (,,) x y z And it worked, giving exactly what I wanted: (x,y,z) This raised the question: How far can you take it? Much to my astonishment, there seemed to be no limit. All of the below are valid operators: (,) (,,) (,,,) (,,,,) --etc (,,,,,,,,,,,,,,) (,,,,,,,,,,,,,,,) --etc (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) --etc This behaviour is amazing and leads to

Decimal group seperator for the fractional part

本小妞迷上赌 提交于 2019-12-02 19:19:34
问题 I wonder what would be the best way to format numbers so that the NumberGroupSeparator would work not only on the integer part to the left of the comma, but also on the fractional part, on the right of the comma. Math.PI.ToString("###,###,##0.0##,###,###,###") // As documented .. // ..this doesn't work 3.14159265358979 // result 3.141,592,653,589,79 // desired result As documented on MSDN the NumberGroupSeparator works only to the left of the comma. I wonder why?? 回答1: A little clunky, and it

C++ %f dot instead of comma

馋奶兔 提交于 2019-12-02 10:40:22
I'm reading a file in c++ where floating point numbers (%f) have a dot instead of comma. Each line in the file has 3 numbers like that 1.000 -1.000 0.000 for example. My app does not want to read the number past the dot, so If I do fscanf(file, "%f %f %f\n", &x, &y, &z ); for example x is set to 1, everything else is left on 0 because it only reads to the first dot. I've already read somewhere that I should change the locale using setlocale or something similar but it didn't work out. Could someone please explain how to do it properly or if there is another way? EDIT: I removed "QT" from the

Decimal group seperator for the fractional part

五迷三道 提交于 2019-12-02 10:38:41
I wonder what would be the best way to format numbers so that the NumberGroupSeparator would work not only on the integer part to the left of the comma, but also on the fractional part, on the right of the comma. Math.PI.ToString("###,###,##0.0##,###,###,###") // As documented .. // ..this doesn't work 3.14159265358979 // result 3.141,592,653,589,79 // desired result As documented on MSDN the NumberGroupSeparator works only to the left of the comma. I wonder why?? A little clunky, and it won't work for scientific numbers but here is a try: class Program { static void Main(string[] args) { var

Find specific value in comma list in database

谁说胖子不能爱 提交于 2019-12-02 10:07:32
In one of my tables, i have a column where it has a comma seperated list of users that have bought that item. IMAGE How can i read the list and run a php script to find if the user that is logged in (that is stored in the Session) is in that list. For example, how could i see if the logged on user (MTNOfficial) is in the list. I think its a php if statement with a mysql CONCAT or FIELD_IN_SET or something. Thanks Use FIND_IN_SET() to find the records that contain your user select * from your_table where find_in_set('MTNOfficial', usersBought) > 0 Get the comma separated list, then try the php

Remove last comma or prevent it from being printed at all MySQL/PHP

孤街浪徒 提交于 2019-12-02 08:38:35
问题 I am printing a set of words that is placed in a MySQL database and I am retrieving it with PHP. I want to present it as a comma separated list, but I need it not to print or remove the last comma. How could I do this? I did try to use rtrim , but I did not probably do it right. This is my code as it is today: <?php $query0 = "SELECT LCASE(ord) FROM `keywords` ORDER BY RAND()"; $result0 = mysql_query($query0); while($row0 = mysql_fetch_array($result0, MYSQL_ASSOC)) { $keyword = $row0['LCASE

Remove last comma or prevent it from being printed at all MySQL/PHP

不羁的心 提交于 2019-12-02 05:11:49
I am printing a set of words that is placed in a MySQL database and I am retrieving it with PHP. I want to present it as a comma separated list, but I need it not to print or remove the last comma. How could I do this? I did try to use rtrim , but I did not probably do it right. This is my code as it is today: <?php $query0 = "SELECT LCASE(ord) FROM `keywords` ORDER BY RAND()"; $result0 = mysql_query($query0); while($row0 = mysql_fetch_array($result0, MYSQL_ASSOC)) { $keyword = $row0['LCASE(ord)']; echo "$keyword, "; ?> I did try to use rtrim , my attempt was something like this (I might be

Trailing comma in JavaScript function call

你。 提交于 2019-12-02 04:03:41
问题 I'm trying to follow the JS code style defined by Airbnb. The rule on trailing commas for function call arguments states: 7.15 Functions with multiline signatures, or invocations, should be indented just like every other multiline list in this guide: with each item on a line by itself, with a trailing comma on the last item. But when I do the following: /* THREE.js constructor for PerspectiveCamera */ const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1,

Trailing comma in JavaScript function call

跟風遠走 提交于 2019-12-02 00:34:21
I'm trying to follow the JS code style defined by Airbnb . The rule on trailing commas for function call arguments states: 7.15 Functions with multiline signatures, or invocations, should be indented just like every other multiline list in this guide: with each item on a line by itself, with a trailing comma on the last item. But when I do the following: /* THREE.js constructor for PerspectiveCamera */ const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000, ); Google Chrome complains with the following error: app.js:11 Uncaught SyntaxError: Unexpected

Split string by commas ignoring any punctuation marks (including ',') in quotation marks

喜夏-厌秋 提交于 2019-12-02 00:26:04
How can I split string (from a textbox) by commas excluding those in double quotation marks ( without getting rid of the quotation marks ), along with other possible punctuation marks (e.g. ' . ' ' ; ' ' - ')? E.g. If someone entered the following into the textbox: apple, orange, "baboons, cows", rainbow, "unicorns, gummy bears" How can I split the above string into the following (say, into a List)? apple orange "baboons, cows" rainbow "Unicorns, gummy bears..." Thank you for your help! You could try the below regex which uses positive lookahead, string value = @"apple, orange, ""baboons, cows