A generic term meaning the process by which text transformed into a more meaningful or clearer output. A typical example would be the transformation of a decimal into a particular currency format with the correct number of decimal places.
6
votes
3answers
74 views
Table printing code using a fluent interface
Let's say you want to display something like:
One Two Three Four
1 2 3 4
And since you hate the idea of predefining the widths of the columns you ...
2
votes
3answers
67 views
Java number formatting in accountant style
I have written a string number formatter. I would like to know if this can be improved and any suggestions with how it's done.
The purpose of this function is to convert a double that has been ...
0
votes
0answers
22 views
Servlet to generate HTML printable form
I'm using a java servlet to generate HTML code to produce a printable form. I want the form to look like the paper version being used now (or as close as possible) to reduce confusion during the ...
0
votes
1answer
27 views
Convert NSInteger into NSString
This is my sample code to convert a integer into string.
Is it very costly to do the multiple loops of [NSMutableString stringWithFormat:..]?
I.e should I just use appendString and get the NSString ...
3
votes
1answer
60 views
Formatting a dirty phone number
Given a String that can contain :
digits
spaces
-
/
I need to format to 3 digits group phone number :
example : "55 5/372-6-5/4" should be ...
4
votes
2answers
57 views
F# function to concatenate some DSL scripts with indentation
I'm rather new to F# and functional programming. I wrote the following method to concatenate some custom dsl scripts. The function works are expected without errors. I wanted to know if there was a ...
3
votes
1answer
43 views
Pretty print a 2D matrix in C (numpy style)
Works for any 2D matrix represented by a 1D array. Comments and criticism welcome. Also wondering whether the code can be made shorter. It's really messy right now.
...
2
votes
2answers
28 views
__str__ method for a tic-tac-toe board
I am making my first object-oriented program in python and I am having trouble with the __str__ part of Board() class. I want it ...
8
votes
2answers
46 views
My own snprintf implementation in C
I decided to make my own version of snprintf in C. I intentionally changed some things though. My version guarantees the buffer printed to will be null-terminated, ...
0
votes
1answer
55 views
Pretify JSON class -followup
This is a follow up to this question. This is an improved version in accordance to comments, suggestions and reviews.
Is the namespace implementation proper? is the code readable? I didn't want to ...
10
votes
3answers
1k views
Prettify JSON class
It's not much, but I tried employing some of the things I learned yet never really got to use, since that kind of code isn't really needed where I work (for the most part). I tried making it as much C+...
10
votes
4answers
2k views
BigInteger formatting for endless tower defense game
I am working on an endless tower defense game in Unity. To keep track of money, damage, hitpoints and stuff like that I will be using BigInteger, which can ...
5
votes
2answers
324 views
itoa base function in C
This is a function that converts an integer value to a null-terminated string using the specified base and stores the result in a char array that I must allocate (...
1
vote
1answer
127 views
Custom Exception.ToString() formatter
I find the default Exception.ToString() formattig very difficult to read especially if there are inner exceptions involved. I guess everyone knows how it looks:
<...
4
votes
1answer
56 views
Binary-octal-hexadecimal conversion table
I solved this exercise of displaying a table of numbers from 1 to 256 in binary, octal and hexadecimal. I made this program to convert from decimal to binary and took that binary number to convert to ...
7
votes
2answers
95 views
Formatting seconds as hours:minutes:seconds
This is basically my school homework and I want to know what to improve, and what not to do.
The homework basically is this:
You will get a input in seconds, which is supposed to be shown as H:MM:SS ...
5
votes
1answer
89 views
Java method to make a string representation of a matrix
I have coded this static method for converting a double matrix into a nifty String.
It considers the width of the matrix to be ...
1
vote
0answers
25 views
Formatting a CHANGES text file as HTML
I have a function which is used to convert text (a CHANGES file) into HTML for reading. The function is essentially line-based: if the line is of this type, do this thing; if some other type, do that ...
2
votes
1answer
54 views
Extendable format provider
I needed a better string formatting options like ToUpper and ToLower but I also wanted to be able to use the default formattings ...
1
vote
1answer
64 views
Exercism: clean and format a phone number in Clojure
Problem statement
Phone Number
Write a program that cleans up user-entered phone numbers so that they can be sent SMS messages.
The rules are as follows:
If the phone number is ...
3
votes
2answers
71 views
Exercise 1-22 from K and R: line folding
I'm currently learning C with K&R, i'm right now in the exercise 1-22, but it's a little... hard to understand (at least for me). It says:
Write a program to "fold" long input lines into two ...
1
vote
2answers
33 views
4
votes
2answers
63 views
Function that strips trailing '0's from a float
I'm writing an embedded application in C, and at one point I need to convert a float into an ASCII representation of that float, so I can send the ASCII over a serial port. The protocol the serial ...
1
vote
0answers
26 views
Simple login script
This is a simple login script using Bcrypt. Is there anything wrong with this code? It works and my page loads O.K, but could this be optimized for better speeds?
...
5
votes
1answer
65 views
K&R 1-20 Solution
I'm currently reading the infamous K&R C book and trying to solve Exercise 1-20. My solution looks kind of too simple, but it works. I've searched the web for different solutions, but they all are ...
2
votes
1answer
49 views
Displaying a String array in tabular format
I have an array of strings called theArray. All strings in theArray are of length 20. I wish to display this array in tabular ...
4
votes
2answers
507 views
Converting all cells to text
Microsoft Excel cells basically have two values: the formatted value that is shown to the user, and the actual value of the cell. These two values can be extremely different when the cell has certain ...
1
vote
1answer
146 views
Remove non-printable characters from string in Python 3
My aim is to print bytes string lines in Python 3, but truncate each line to a maximum width so that it fits the current terminal window.
My first attempt was only ...
3
votes
1answer
58 views
Type safe variadic cout implementation
I use console a lot, so I thought this may help me. It's supposed to be simple, safe, and fast. Any ideas?
http://ideone.com/INXub0
...
4
votes
4answers
191 views
Helper function to format-output any type of variable
This question has already got some reviews, so I could partially improve my code: please look at my self-answer below, which also contains comments about the review.
I'm frequently interested to ...
6
votes
2answers
132 views
Prime multiplication table
I am new to Ruby (1 year as hobby project on weekends) and solved a code challenge and it was not as good as they wanted. I want to know how i could make it better and how to make the structure better....
15
votes
4answers
823 views
Generating formatted multiplication tables in C++
I am self studying C++ from Robert Lafore's OOP in C++. I am solving the first exercise questions of chapter-3 loop and decisions. I've written three different codes using different approaches. I want ...
4
votes
2answers
102 views
Colorful output on terminal
I went from manually outputting escape codes in each string to creating a utility struct/class full of static functions and variables that needed to be initialized in source files (static private ...
2
votes
1answer
61 views
Basic JSON Representation in Rust
This week I started reading "The Rust Programming Language". As I reached the chapters on enumerations and pattern matching I felt I had enough material to put together a simple representation of JSON ...
3
votes
1answer
120 views
Timestamp function with millisecond precision
I want to be able to print timestamps with milliseconds precision and time_t doesn't provide this. I also want the code to be portable, so operating specific ...
20
votes
0answers
340 views
Printing binary trees
After writing this answer, I was inspired to try to design a more elegant solution to the problem of printing binary trees. And what better tool with which to seek elegance than Clojure?
Overall ...
4
votes
1answer
79 views
Preventing numbers from showing up in scientific notation
We have a StreamBuffer class which is not inherited from std::ios_base (or some of it's derivatives such as ...
-3
votes
2answers
43 views
Display calendar using a loop
Desired output:
Can I get an shorter version of this code? My instructor just wants me to figure it out my self.
...
5
votes
2answers
81 views
Library assistant
HackerRank currently has '7 days of JavaScript' going, a quick intro into the JavaScript language. Every day a couple of challenges will be made available. One of the challenges of today was this:
...
4
votes
1answer
86 views
Syntax highlighter for HTML and PHP
I've created a JavaScript application to highlight the syntax of HTML and PHP. I know a lot of syntax highlighter are available nowadays, I just created to extend my knowledge in JS and regular ...
-1
votes
1answer
59 views
5
votes
0answers
188 views
Document formatting markup engine in Postscript
I've been rewriting this same sort of thing off and on over the years, but finally here's the "perfected" monstrosity. Some kruft in the middle with attempting to predict the number of spaces that ...
6
votes
1answer
50 views
Printing a nested data structure in Clojure
I wrote the following code which transforms a nested data structure
...
1
vote
2answers
59 views
Converting an angle in degrees to a pretty string representing it in radians
Given an angle in degrees, output a pretty string representation of its value in radians as a fraction.
Where pretty means:
Simplified as much as possible.
With no unnecessary ones.
Using the ...
8
votes
1answer
205 views
Pretty printing degrees input to radians
I'm mostly concerned about edge cases, although I think I dealt with them all. Improvements on code quality would also be much appreciated.
...
4
votes
3answers
334 views
Use va_list to format a string
I wrote a function that basically works like sprintf, but instead returns the formatted string (std::string). I haven't worked ...
2
votes
1answer
55 views
Printing an array in columns
I'm trying to define a function which takes an array and prints it to a predefined total width in as many columns as needed. Think of the way ls prints files for ...
6
votes
1answer
56 views
Convert data back-and-forth between CSV files and pretty-print
I wrote a script to convert CSV files in human readable format and vice versa.
Human readable format is achieved like so:
...
0
votes
2answers
107 views
JLabel formatting on GPA calculator
I am currently working on a GPA Calculator side project over holiday break to become more familiar with Swing, but I find the number formatting is more complicated than in regular Java. At the moment ...
14
votes
2answers
140 views
Formatted print without the need to specify type matching specifiers using _Generic
This code allows printing in C with a style similar to C++ ostream. By using _Generic() (see ...