Welcome to W3Courses
 Like Us on Facebook

Programming

Check if a list is Shorter than the Other using Scheme Source Code

The following code checks if a list is shorter than the other

CODE
(define shorter(lambda(x y)
          (cond ((null? x) 1)
                ((null? y) 0)
                (else (shorter (cdr x) (cdr y)))))

Share

Stack Function using Scheme Source Code

Stack function code

Share

Sum all Integers between given Two Integers using Scheme Source Code

The following code sums all integers between given two integers

CODE
 (define (sumall a b)
      (cond ((= a b) a)
            (else (+ a (sumall (+ a 1) b)))))


The following will add 2+3+4+5

RESULT
> (sumall 2 5)
14

Share

Tower of Hanoi Function using Scheme Source Code

Tower of Hanoi function code

 (define (hanoi n a b c)
      (if (eqv? n 0) '()
      (append (hanoi (- n 1) a c b)
            (list (cons a b))
            (hanoi (- n 1) c b a))))

Share

Tree Function using Scheme Source Code

Tree function code

Share

String Replace Function in C#

The following code will replace a character or a word with some other character or a word. This is accomplished by the replace function in C#.

using System;
using System.Text.RegularExpressions;

string strReplace;
strReplace = "This is a test string.";
strReplace = Regex.Replace(strReplace, " is", " was");

Share

Rename a File on the Disk or Local File System using C#

The following code will rename a file called temp.txt to tempnew.txt

using System.IO;

Share

Display Current Date Automatically on your Website using JavaScript

The following code displays the current date with month and year in the following format:

September 20, 2007

<script>
<!-- //Hide From Old Browsers

/*
   Do Not Remove the Following Line
   For more scripts visit http://www.w3courses.com
*/

Share

How to Create a Reload Button which will Reload the Webpage upon Clicking using JavaScript

The following code will add a reload button to your webpage. This button will reload your webpage when clicked.

Place the following code in the body section of your webpage where you want to display the button

<form>
<INPUT TYPE="button" VALUE="Reload" onClick='parent.location="javascript:location.reload()"'>
</form>

Share

Automatically Redirect from one Webpage to Another Webpage using JavaScript

Add the following code to the head section of your webpage to automatically redirect your users to another page.

<SCRIPT>
location.href = "http://www.w3courses.com"
</SCRIPT>
 

Share