[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

370.0. "Recursive functions in DCL?" by THEBUS::KOSTAS (Wisdom is the child of experience.) Fri Dec 12 1986 11:55

    Hello,
      
      I was wandering if anyone has implemented a recurvice function
    using DCL. I like to see the function factorial if possible.
    
    -kgg
    
    
T.RTitleUserPersonal
Name
DateLines
370.1Recursive Procedure FACTBARNA::SOLEPONTFri Dec 12 1986 16:5817
    Usage:	$ @FACT number
		$ sh sym RE

    Limits:	0<=number<=16

    Sources:

	-- FACT.com ------------------------------------------------
			$ if p1 .le. 1 then goto A
			$	par = 'p1 - 1
			$	@fact 'par
			$	re == re*'p1
			$ exit
			$A:	re == 1
	------------------------------------------------------------

    *Jaume	(and it's faster than my 5 lines solution ;-)
370.2here's a real interesting graphic (recursive!)REGINA::OSMANand silos to fill before I feep, and silos to fill before I feepFri Dec 12 1986 17:2095
$!
$!	Here's an example of a recursive function in DCL, which prints
$!	fascinating Hilbert curves.  IT REQUIRES A REGIS TERMINAL, SUCH AS
$!	VT240.
$!
$!	Save this procedure as HILBERT.COM.  Then, run it with
$!
$!		$ @HILBERT 4
$!
$!	Then, you can experiment with other small integers.
$!
$!	Author: Eric Osman 12/12/86
$!
$ all_options = p3 + p4 + p5 + p6 + p7 + p8
$ debug_flag = all_options .nes. ""
$ if .not. debug_flag then on control_y then goto leave
$ esc[0,8] = 27
$ if debug_flag then esc = "`"
$ s = p2
$ if s .eqs. "" then s = 15
$ level = 0
$ h0 = 180
$ hx180 = -1
$ hy180 = 0
$ h1 = 90
$ hx90 = 0
$ hy90 = 1
$ h2 = 0
$ hx0 = 1
$ hy0 = 0
$ h3 = 270
$ hx270 = 0
$ hy270 = -1
$ width = 800
$ height = 500
$ h = 270
$ !if .not. debug_flag then -
$ write sys$output "''esc'[2J''"
$ x = 0
$ y = 22 * height / 24
$ write sys$output "''esc'P1pP[''x',''y']"
$ whereto'level = "m0"
$ newarg = p1
$ if newarg .eqs. "" then newarg = 5
$ goto recursing
$m0: goto leave
$!
$recursing: level = level + 1
$ n'level = newarg
$ if n'level .eq. 0 then goto is0
$ a'level = 90 - (n'level .lt. 0) * 180
$ m'level = n'level + (n'level .lt. 0) * 2 - 1
$ h = h + a'level		! turn: a
$ newarg = 0 - m'level
$ whereto'level = "tag1"
$ goto recursing		! hilbert: 0 - m side: s
$tag1: h = h + a'level		! turn: a
$ h = h - h/360*360
$ if h .lt. 0 then h = h + 360
$ x = x + s*hx'h
$ y = y + s*hy'h
$ write sys$output "V[''x',''y']"
$ newarg = m'level
$ whereto'level = "tag2"
$ goto recursing		! hilbert: m side: s
$tag2: h = h - a'level		! turn: 0 - a
$ h = h - h/360*360
$ if h .lt. 0 then h = h + 360
$ x = x + s*hx'h
$ y = y + s*hy'h
$ write sys$output "V[''x',''y']"
$ h = h - a'level		! turn: 0 - a
$ newarg = m'level
$ whereto'level = "tag3"
$ goto recursing		! hilbert: m side: s
$tag3: h = h - h/360*360
$ if h .lt. 0 then h = h + 360
$ x = x + s*hx'h
$ y = y + s*hy'h
$ write sys$output "V[''x',''y']"
$ h = h + a'level		! turn: a
$ newarg = 0 - m'level
$ whereto'level = "tag4"
$ goto recursing		! hilbert: 0 - m side: s
$tag4: h = h + a'level		! turn: a
$ goto exit_please

$is0: h = h + 180			! ^turn: 180
$exit_please: level = level - 1
$ tag = whereto'level
$ goto 'tag
$!
$!
$leave: write sys$output ";''esc'/''esc'[24;1f''esc'[K''esc'[A"
$ exit
370.3what about Sierpinski curves? . . .CASSAN::KOSTASWisdom is the child of experience.Sun Dec 14 1986 00:0928
    re. .2
    
    Incredible! 
    
    How much effor will it take to be able to graph Sierpinski curves
    or have support for in hilbert.com? I am interested to see the Greek
    Cross (which I think he structure is similar to that of the Sierpinski
    curves.)
    
    i.e. 
    
    order 1 of the Greek Cross
    
            +------+
            |      |
            |      |
      +-----+      +-----+
      |                  |
      |                  |
      +-----+      +-----+
            |      |
            |      |
            +------+

    
    thanks,
    
    Kostas G.