<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Snipplr</title>
    <description>Recent snippets posted on Snipplr.com</description>
    <link>https://snipplr.com/</link>
    <lastBuildDate>Tue, 09 Jun 2026 13:24:26 +0000</lastBuildDate>
    <item>
      <title>(XML) Create a Webservice Client using Maven ws-import Plugin - rtperson</title>
      <link>https://snipplr.com/view/72094/create-a-webservice-client-using-maven-wsimport-plugin</link>
      <description>&lt;p&gt;Use this if you need Maven to automatically create a SOAP client for you.&lt;/p&gt;</description>
      <pubDate>Sun, 11 Aug 2013 12:14:12 UTC</pubDate>
      <guid>https://snipplr.com/view/72094/create-a-webservice-client-using-maven-wsimport-plugin</guid>
    </item>
    <item>
      <title>(C) Radix Conversion In C - rtperson</title>
      <link>https://snipplr.com/view/68873/radix-conversion-in-c</link>
      <description>&lt;p&gt;How to convert an integer from base 10 to a string of base x (where x &lt;= 20). The #define RESERVE_CHARS should be set to the largest size for the resulting string. Or feel free to adjust the code to reallocate storage for the string.&lt;/p&gt;</description>
      <pubDate>Sun, 02 Dec 2012 12:45:17 UTC</pubDate>
      <guid>https://snipplr.com/view/68873/radix-conversion-in-c</guid>
    </item>
    <item>
      <title>(C) Palindrome Check In C - rtperson</title>
      <link>https://snipplr.com/view/68872/palindrome-check-in-c</link>
      <description>&lt;p&gt;A palindrome is a string that reads the same both backwards and forwards. Famous examples are "Madam I'm Adam" or "Able was I ere I saw Elba". This function checks that a given string reads the same backwards and forwards. (requires including stdbool.h)&lt;/p&gt;</description>
      <pubDate>Sun, 02 Dec 2012 12:43:58 UTC</pubDate>
      <guid>https://snipplr.com/view/68872/palindrome-check-in-c</guid>
    </item>
    <item>
      <title>(C) Ternary Counting In C - rtperson</title>
      <link>https://snipplr.com/view/68870/ternary-counting-in-c</link>
      <description>&lt;p&gt;Here's a fairly useless but fun piece of code: counting in base 3. This takes in a number of  digits and counts up in ternary. Be warned, though. The algorithm is (for obvious reasons) O(n^3), where n is the number of digits. Actually probably theta(n^3), since n^3 is both the upper and lower bound. Either way, it spits out 531,441 possibilities for 12 digits, so be careful not to run it on too many digits.&lt;/p&gt;</description>
      <pubDate>Sun, 02 Dec 2012 12:41:23 UTC</pubDate>
      <guid>https://snipplr.com/view/68870/ternary-counting-in-c</guid>
    </item>
    <item>
      <title>(PL/SQL) How To Change The Value Of A Sequence In PL/SQL - rtperson</title>
      <link>https://snipplr.com/view/68869/how-to-change-the-value-of-a-sequence-in-plsql</link>
      <description>&lt;p&gt;I'm pretty meh about Oracle's PL/SQL, but its inability to reference and change sequences has been pretty frustrating over the years. Until now. Thanks to the Puget Sound Oracle Users Group's website (psoug.org) for showing me how to do this.&lt;/p&gt;</description>
      <pubDate>Sun, 02 Dec 2012 12:39:22 UTC</pubDate>
      <guid>https://snipplr.com/view/68869/how-to-change-the-value-of-a-sequence-in-plsql</guid>
    </item>
    <item>
      <title>(C++) Calendar Calculation in C++ - rtperson</title>
      <link>https://snipplr.com/view/68867/calendar-calculation-in-c</link>
      <description>&lt;p&gt;Brute-force calculation of any date. Includes some very tricky rules for modern-day Gregorian calendar.&lt;/p&gt;</description>
      <pubDate>Sun, 02 Dec 2012 12:36:50 UTC</pubDate>
      <guid>https://snipplr.com/view/68867/calendar-calculation-in-c</guid>
    </item>
    <item>
      <title>(C++) Using a Map for Dynamic Programming in C++ - rtperson</title>
      <link>https://snipplr.com/view/68866/using-a-map-for-dynamic-programming-in-c</link>
      <description>&lt;p&gt;Really DP-lite. Memoize the solution for a recursive problem so it can be looked up on subsequent iterations.&lt;/p&gt;</description>
      <pubDate>Sun, 02 Dec 2012 12:34:58 UTC</pubDate>
      <guid>https://snipplr.com/view/68866/using-a-map-for-dynamic-programming-in-c</guid>
    </item>
    <item>
      <title>(Haskell) Linked List in C - rtperson</title>
      <link>https://snipplr.com/view/68865/linked-list-in-c</link>
      <description>&lt;p&gt;I bit of overkill for USACO's "Milk2" algorithm training problem. This problem would be better suited to an interval tree, but here it is.&lt;/p&gt;</description>
      <pubDate>Sun, 02 Dec 2012 12:32:20 UTC</pubDate>
      <guid>https://snipplr.com/view/68865/linked-list-in-c</guid>
    </item>
    <item>
      <title>(Haskell) Binary Search in Haskell - rtperson</title>
      <link>https://snipplr.com/view/68840/binary-search-in-haskell</link>
      <description>&lt;p&gt;Improved version, using lenses instead of the dangerous (!!) operator for list access.&lt;/p&gt;</description>
      <pubDate>Fri, 30 Nov 2012 14:16:50 UTC</pubDate>
      <guid>https://snipplr.com/view/68840/binary-search-in-haskell</guid>
    </item>
    <item>
      <title>(Java) Scaling Values into a range between 0 and 1 - rtperson</title>
      <link>https://snipplr.com/view/66636/scaling-values-into-a-range-between-0-and-1</link>
      <description>&lt;p&gt;You have to use float or double for the returned value, since the scale occurs in a continuous function.&lt;/p&gt;</description>
      <pubDate>Fri, 10 Aug 2012 11:35:33 UTC</pubDate>
      <guid>https://snipplr.com/view/66636/scaling-values-into-a-range-between-0-and-1</guid>
    </item>
    <item>
      <title>(Java) Quicksort in Java, with Enforced Suckitude - rtperson</title>
      <link>https://snipplr.com/view/64808/quicksort-in-java-with-enforced-suckitude</link>
      <description>&lt;p&gt;It's no fun implementing QuickSort unless you can force it out of its blister-fast, O(n log n) speed and humiliate it with its worst-case, O(n^2) runtime. So that's what I set out to do.  &#13;
&#13;
My naive partition simply pivots around the low item, but my randomized partition defeats the sucky inputs by choosing a random pivot. (If you're interested in checking out a QuickSort which naively partitions until it hits an attempt to get it to run in quadratic time, check out IntroSort -- which simply  fails over to Merge Sort when it exceeds its optimal recursion depth.)&lt;/p&gt;</description>
      <pubDate>Tue, 08 May 2012 00:02:25 UTC</pubDate>
      <guid>https://snipplr.com/view/64808/quicksort-in-java-with-enforced-suckitude</guid>
    </item>
    <item>
      <title>(C) Two Binary Search Functions in C - rtperson</title>
      <link>https://snipplr.com/view/63046/two-binary-search-functions-in-c</link>
      <description>&lt;p&gt;Two versions of binary search -- one recursive, one iterative -- for an array of strings.&#13;
Both assume that your array index fits within an integer.&lt;/p&gt;</description>
      <pubDate>Sat, 04 Feb 2012 02:45:29 UTC</pubDate>
      <guid>https://snipplr.com/view/63046/two-binary-search-functions-in-c</guid>
    </item>
    <item>
      <title>(Haskell) Haskell 99 Problems - Problem 23 - rtperson</title>
      <link>https://snipplr.com/view/58582/haskell-99-problems--problem-23</link>
      <description>&lt;p&gt;problem 23, Extract a given number of randomly selected elements from a list. &#13;
    Example:&#13;
&#13;
    Prelude System.Random&gt;rnd_select "abcdefgh" 3 &gt;&gt;= putStrLn&#13;
&#13;
        "eda"&#13;
        &#13;
    Two problems: 1) How to return a list, and 2) how to sample without duplication&lt;/p&gt;</description>
      <pubDate>Sat, 10 Sep 2011 07:27:49 UTC</pubDate>
      <guid>https://snipplr.com/view/58582/haskell-99-problems--problem-23</guid>
    </item>
    <item>
      <title>(Haskell) Haskell 99 Problems, numbers 1 through 9 - rtperson</title>
      <link>https://snipplr.com/view/58509/haskell-99-problems-numbers-1-through-9</link>
      <description>&lt;p&gt;I had originally started these problems from #10 (Run-length encoding). I went back and did 1-8 for completeness.&lt;/p&gt;</description>
      <pubDate>Thu, 08 Sep 2011 00:23:54 UTC</pubDate>
      <guid>https://snipplr.com/view/58509/haskell-99-problems-numbers-1-through-9</guid>
    </item>
    <item>
      <title>(Haskell) Haskell 99 Problems - Number 20,  Arrowed! - rtperson</title>
      <link>https://snipplr.com/view/58144/haskell-99-problems--number-20--arrowed</link>
      <description>&lt;p&gt;problem 20, (*) Remove the K'th element from a list&#13;
&#13;
    *Main&gt; removeAt 1 "abcd"&#13;
        "acd"&#13;
&#13;
Trivial using a pure function. A bit more challenging if you use this problem to work up your Arrow-fu.&lt;/p&gt;</description>
      <pubDate>Thu, 25 Aug 2011 01:54:30 UTC</pubDate>
      <guid>https://snipplr.com/view/58144/haskell-99-problems--number-20--arrowed</guid>
    </item>
    <item>
      <title>(Haskell) Haskell 99 Problems - Number 17 - rtperson</title>
      <link>https://snipplr.com/view/57981/haskell-99-problems--number-17</link>
      <description>&lt;p&gt;problem 17, Split a list into two parts; the length of the first part is given. &#13;
    Do not use any predefined predicates. (Meaning no splitAt or take or drop)&#13;
    *Main&gt; split "abcdefghik" 3&#13;
            ("abc", "defghik")&lt;/p&gt;</description>
      <pubDate>Thu, 18 Aug 2011 06:50:09 UTC</pubDate>
      <guid>https://snipplr.com/view/57981/haskell-99-problems--number-17</guid>
    </item>
    <item>
      <title>(Haskell) Haskell 99 Problems - Numbers 15 and 16 - rtperson</title>
      <link>https://snipplr.com/view/57971/haskell-99-problems--numbers-15-and-16</link>
      <description>&lt;p&gt;problem 15, Replicate the elements of a list a given number of times. &#13;
    &gt; repli "abc" 3&#13;
        "aaabbbccc"&#13;
&#13;
    problem 16, Drop every N'th element from a list. &#13;
    *Main&gt; dropEvery "abcdefghik" 3&#13;
        "abdeghk"&lt;/p&gt;</description>
      <pubDate>Thu, 18 Aug 2011 03:59:30 UTC</pubDate>
      <guid>https://snipplr.com/view/57971/haskell-99-problems--numbers-15-and-16</guid>
    </item>
    <item>
      <title>(Haskell) Haskell 99 Problems - Number 14 - rtperson</title>
      <link>https://snipplr.com/view/57921/haskell-99-problems--number-14</link>
      <description>&lt;p&gt;problem 14, Duplicate the elements of a list&#13;
    &gt; dupli [1, 2, 3]&#13;
        [1,1,2,2,3,3]&lt;/p&gt;</description>
      <pubDate>Thu, 18 Aug 2011 01:04:04 UTC</pubDate>
      <guid>https://snipplr.com/view/57921/haskell-99-problems--number-14</guid>
    </item>
    <item>
      <title>(Haskell) Haskell 99 Problems - Solutions to 11 and 12 - rtperson</title>
      <link>https://snipplr.com/view/57309/haskell-99-problems--solutions-to-11-and-12</link>
      <description>&lt;p&gt;problem 11, modified run-length encoding&#13;
========================================&#13;
If an element has no duplicates, mark it as such. &#13;
&#13;
Example:&#13;
&#13;
    encodeModified "aaaabccaadeeee"&#13;
&#13;
    [Multiple 4 'a',Single 'b',Multiple 2 'c',&#13;
        Multiple 2 'a',Single 'd',Multiple 4 'e']&#13;
&#13;
problem 12, Decode a run-length encoded list. &#13;
=============================================&#13;
Given a run-length code list generated as specified in problem 11. Construct its uncompressed version. &#13;
&#13;
Example:&#13;
&#13;
    decodeModified &#13;
       [Multiple 4 'a',Single 'b',Multiple 2 'c',&#13;
        Multiple 2 'a',Single 'd',Multiple 4 'e']&#13;
&#13;
    "aaaabccaadeeee"&lt;/p&gt;</description>
      <pubDate>Fri, 29 Jul 2011 08:03:55 UTC</pubDate>
      <guid>https://snipplr.com/view/57309/haskell-99-problems--solutions-to-11-and-12</guid>
    </item>
    <item>
      <title>(Haskell) Run-Length Encoding in Haskell - rtperson</title>
      <link>https://snipplr.com/view/57300/runlength-encoding-in-haskell</link>
      <description>&lt;p&gt;Problem 10 of the famous 99 Problems. I got 99 problems, but a Lisp ain't one.&lt;/p&gt;</description>
      <pubDate>Fri, 29 Jul 2011 06:08:49 UTC</pubDate>
      <guid>https://snipplr.com/view/57300/runlength-encoding-in-haskell</guid>
    </item>
    <item>
      <title>(Haskell) Towers of Hanoi by Bit Twiddling - rtperson</title>
      <link>https://snipplr.com/view/56194/towers-of-hanoi-by-bit-twiddling</link>
      <description>&lt;p&gt;Credit where it's due: I got this from udpn over at codereview.stackexchange.com. I'm just putting it here for further study.&lt;/p&gt;</description>
      <pubDate>Thu, 07 Jul 2011 01:45:07 UTC</pubDate>
      <guid>https://snipplr.com/view/56194/towers-of-hanoi-by-bit-twiddling</guid>
    </item>
    <item>
      <title>(Haskell) Towers of Hanoi in Haskell - rtperson</title>
      <link>https://snipplr.com/view/56191/towers-of-hanoi-in-haskell</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 07 Jul 2011 01:05:06 UTC</pubDate>
      <guid>https://snipplr.com/view/56191/towers-of-hanoi-in-haskell</guid>
    </item>
    <item>
      <title>(Haskell) Real World Haskell Exercise - Ch 4 - rtperson</title>
      <link>https://snipplr.com/view/54660/real-world-haskell-exercise--ch-4</link>
      <description>&lt;p&gt;The first fold exercise from RWH, Chapter 4&lt;/p&gt;</description>
      <pubDate>Wed, 01 Jun 2011 01:00:47 UTC</pubDate>
      <guid>https://snipplr.com/view/54660/real-world-haskell-exercise--ch-4</guid>
    </item>
    <item>
      <title>(Haskell) Real World Haskell Exercise - Ch 4, Ex 2-4 - rtperson</title>
      <link>https://snipplr.com/view/54659/real-world-haskell-exercise--ch-4-ex-24</link>
      <description>&lt;p&gt;I'm posting the rest of these, mostly because I'm still patting myself on the back for my point-free implementation of exercise 3, and because I give myself about two months before I entirely forget how I did it...&lt;/p&gt;</description>
      <pubDate>Wed, 01 Jun 2011 00:59:27 UTC</pubDate>
      <guid>https://snipplr.com/view/54659/real-world-haskell-exercise--ch-4-ex-24</guid>
    </item>
    <item>
      <title>(Haskell) Fibonacci List One-Liner in Haskell - rtperson</title>
      <link>https://snipplr.com/view/54657/fibonacci-list-oneliner-in-haskell</link>
      <description>&lt;p&gt;I didn't invent this, but it's too cool a snippet not to capture. Here's a one-liner that will generate a list of Fibonacci numbers in linear time.&#13;
&#13;
EXPLANATION: the colon operator is used to add elements to a list, so it starts out adding on the two base cases, zero and one. After you have these two, you can mathematically generate the rest of the list. The zipWith function takes two lists and combines them using a function (in this case, addition). The two lists in question are fiblist (that is, the list you're currently generating) and "tail fiblist" (that is, every element of the list after the first element). &#13;
&#13;
The only reason this works is because Haskell's laziness gives it the ability to define infinite lists. Haskell will never even attempt to calculate the nth Fibonacci number until it is asked to do so.&lt;/p&gt;</description>
      <pubDate>Wed, 01 Jun 2011 00:44:37 UTC</pubDate>
      <guid>https://snipplr.com/view/54657/fibonacci-list-oneliner-in-haskell</guid>
    </item>
    <item>
      <title>(Haskell) Haskell Radix Conversion using ByteStrings - rtperson</title>
      <link>https://snipplr.com/view/54655/haskell-radix-conversion-using-bytestrings</link>
      <description>&lt;p&gt;Another radix conversion, when you need to zippy greatness of Haskell's ByteString.(Haskell strings are slooooow!)&#13;
&#13;
TODO: rewrite this using overloaded strings.&lt;/p&gt;</description>
      <pubDate>Wed, 01 Jun 2011 00:30:19 UTC</pubDate>
      <guid>https://snipplr.com/view/54655/haskell-radix-conversion-using-bytestrings</guid>
    </item>
    <item>
      <title>(Haskell) Haskell Radix Conversion - rtperson</title>
      <link>https://snipplr.com/view/54654/haskell-radix-conversion</link>
      <description>&lt;p&gt;Converts an integer from base 10 to a string of base x (where 0 &gt; x &gt;= 20). The only thing I'd improve is getting rid of all the calls to error. Perhaps hand back a Maybe String that simply hands back Nothing if unable to convert the number.&lt;/p&gt;</description>
      <pubDate>Wed, 01 Jun 2011 00:26:01 UTC</pubDate>
      <guid>https://snipplr.com/view/54654/haskell-radix-conversion</guid>
    </item>
    <item>
      <title>(Haskell) FizzBuzz in Haskell - rtperson</title>
      <link>https://snipplr.com/view/54653/fizzbuzz-in-haskell</link>
      <description>&lt;p&gt;The dread FizzBuzz question -- really, a test if your average programmer knows his or her FOR loops. The spec is that you're counting from 1 to 100. Your program should print out "fizz" if the index is divisible by three, and "buzz" if it's divisible by five, and "fizzbuzz" if it's divisible by both.&#13;
&#13;
I have a couple different versions in this code: first, a few functions just fizzing or buzzing. Second, a generalization which allows any standard message against any divisor. Third, a purely functional version that zips two lists together (giving us free concatenation for "fizzbuzz"). Fourth, a list comprehension and lastly, a monadic version that calls a pure function that uses guards.&lt;/p&gt;</description>
      <pubDate>Wed, 01 Jun 2011 00:14:43 UTC</pubDate>
      <guid>https://snipplr.com/view/54653/fizzbuzz-in-haskell</guid>
    </item>
    <item>
      <title>(C) Odometer-like Brute-force Counter in C - rtperson</title>
      <link>https://snipplr.com/view/54650/odometerlike-bruteforce-counter-in-c</link>
      <description>&lt;p&gt;Given a sorted set of digits, print all of them in counting order.&#13;
digits[] - the set of digits allowed. They are assumed to be in the set {0-9}, but it will work with larger numbers as well.&#13;
    range - the length of the resulting number (i.e., how many digits to print)&#13;
    numDigits - the size of the set of digits represented by digits[]&#13;
&#13;
There are probably slicker ways to do this: see http://stackoverflow.com/questions/228796/algorithm-odometer-brute-force&#13;
but this one is fast.&lt;/p&gt;</description>
      <pubDate>Wed, 01 Jun 2011 00:02:09 UTC</pubDate>
      <guid>https://snipplr.com/view/54650/odometerlike-bruteforce-counter-in-c</guid>
    </item>
    <item>
      <title>(C) Digit Check in C - rtperson</title>
      <link>https://snipplr.com/view/54626/digit-check-in-c</link>
      <description>&lt;p&gt;Check that a given integer consists only of elements of a given set. It does a linear search through the set, so the assumption is that the set to search is relatively small. If you're chewing through a particularly large set of digits, you may want to sort your set and implement a binary search.&lt;/p&gt;</description>
      <pubDate>Tue, 31 May 2011 10:43:04 UTC</pubDate>
      <guid>https://snipplr.com/view/54626/digit-check-in-c</guid>
    </item>
  </channel>
</rss>
