•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Software Developers' Lounge section within the Software Development category of DaniWeb, a massive community of 391,905 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,563 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Software Developers' Lounge advertiser:
Views: 12236 | Replies: 81
![]() |
•
•
Join Date: May 2006
Location: Ontario, Canada
Posts: 18
Reputation:
Rep Power: 3
Solved Threads: 2
I just started teaching myself O'Caml 

let rec range s f =
if s > f then []
else s :: range (s + 1) f ;;
let count s f =
List.iter (fun i -> Printf.printf "%d " i) (range s f) ;;
count 1 10 ;; Last edited by Jessehk : Aug 4th, 2006 at 11:01 pm.
--Jessehk
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 936
Reputation:
Rep Power: 5
Solved Threads: 47
XML/XSLT
I guess XML isn't a language, and XSLT doesn't have to be, but this is certainly programmatic. It requires an input XML file and produces an HTML output file with the numbers one to ten separated by line breaks. The elements in the XML input file are irrelevant, as long as the root element is called "lots", and every "lots" element contains one more "lots" element than its parent. Until you get to ten of course.
Here's the input file (lots.xml)
And heres the XSLT stylesheet:
Matt
I guess XML isn't a language, and XSLT doesn't have to be, but this is certainly programmatic. It requires an input XML file and produces an HTML output file with the numbers one to ten separated by line breaks. The elements in the XML input file are irrelevant, as long as the root element is called "lots", and every "lots" element contains one more "lots" element than its parent. Until you get to ten of course.
Here's the input file (lots.xml)
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="countem.xsl"?> <lots> <lots><lots><lots> <lots><lots><lots> <lots><lots><lots> <right /><what /><we /><are /><going /><to /> <do /><here /><is /><create /></lots><of /> <elements /><infact /><they /><are /><xml /> <elements /><and /></lots><of /><them /><are /> <in /><this /><file /><yes /></lots><of /><em /> <doesnt /><matter /><whats /><in /></lots><of /> <them /><because /><most /><infact /></lots><of /> <them /><are /><just /></lots><and /><thats /> <got /></lots><of /><importance /></lots><and /> </lots> </lots>
And heres the XSLT stylesheet:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <html> <head><title>Count to ten!</title></head> <body> <xsl:apply-templates select="lots"/> </body> </html> </xsl:template> <xsl:template match="lots"> <xsl:value-of select="count(*)"/> <br /> <xsl:apply-templates select="lots"/> </xsl:template> </xsl:stylesheet>
Matt
Last edited by MattEvans : Sep 1st, 2006 at 3:20 am.
If it only works in Internet Explorer; it doesn't work.
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 936
Reputation:
Rep Power: 5
Solved Threads: 47
By programming myBrain (in real-time) to use the "handwriting" library : system requirements included "pencil" and "paper" : tested in the "my kitchen" environment only.
Yep that's right, I wrote down the numbers 1 to 10 on a piece of paper. It had a very short implementation time, and I even drew a squiggly line around the numbers when I'd finished.
I unfortunately can't provide any evidence to support this feat - you'll just have to trust me.
Matt
Yep that's right, I wrote down the numbers 1 to 10 on a piece of paper. It had a very short implementation time, and I even drew a squiggly line around the numbers when I'd finished.
I unfortunately can't provide any evidence to support this feat - you'll just have to trust me.
Matt
If it only works in Internet Explorer; it doesn't work.
•
•
Join Date: Jun 2005
Location: Novi Sad, Serbia
Posts: 273
Reputation:
Rep Power: 6
Solved Threads: 29
MIPS assembler. Using SPIM simulator
.data
str1: .asciiz "1 2 3 4 5 6 7 8 9 10"
.globl main
.text
main:
la $a0, str1 # load string address into $a0 and I/O code into $v0
li $v0, 4
syscall # execute the syscall to perform input/output
# via the console
li $v0, 10 # syscall code 10 for terminating the program
syscall
If you want to win, you must not loose (Alan Ford)
Just been playing about with C++ Templates, and thought of this thread 
(By the way, only 44 posts?! we can do better than that...! )

(By the way, only 44 posts?! we can do better than that...! )
#include <iostream>
template<int i> void count()
{
std::cout << i << std::endl;
count<i+1>();
}
template<> void count<10>()
{
std::cout << 10 << std::endl;
}
int main()
{
count<1>();
} Last edited by Bench : Sep 4th, 2006 at 5:56 pm.
¿umop apisdn upside down? •
•
Join Date: May 2006
Location: Ontario, Canada
Posts: 18
Reputation:
Rep Power: 3
Solved Threads: 2
That we can. On the forum where I stole this idea, we got to 500.

#include <iostream>
template <int n>
class Counter {
public:
Counter() {
Counter<n - 1> count;
std::cout << n << std::endl;
}
};
template <>
class Counter<0> {
public:
Counter() {}
};
int main() {
Counter<10> count;
}EDIT: I'm in shock! I'm sorry that my code is so similar to yours. It was a complete coincidence. :eek:
Last edited by Jessehk : Sep 4th, 2006 at 9:33 pm.
--Jessehk
•
•
Join Date: Jun 2005
Location: Novi Sad, Serbia
Posts: 273
Reputation:
Rep Power: 6
Solved Threads: 29
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Software Developers' Lounge Marketplace
•
•
•
•
ajax asp blog browsing bt business business software creative design developer development devices erp systems experiment firefox howto illustrator india internet malware mcafee media microsoft mmorpg msdn news office online open-source photoshop print project management publishing rss search security software software selection spyware sql super technology evaluation tips toread vista warez web wiki windows
- Previous Thread: Viewing .cdr extension files
- Next Thread: Debuging


Linear Mode