Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 22nd, 2012, 02:04 PM
bandyc bandyc is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 2 bandyc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 19 sec
Reputation Power: 0
DrRacket procedure

I am working a bit with DrRacket and have a procedure I am having difficultly writing and executing. I want to take two ATOMS "X" and "N'. I want to add "X" to "X" for "N" number of times. i.e. for X is 2 and N is 5, I want 22222.
Thanks in advance for any help or suggestions you have

Reply With Quote
  #2  
Old October 22nd, 2012, 06:25 PM
OmegaZero OmegaZero is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2007
Posts: 737 OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 23 m 50 sec
Reputation Power: 928
(BTW--you may attract more attention by saying "Scheme" instead of "DrRacket". Most of us recognize former, but need to look up the latter.)

It is helpful to see what progress you've made (and helps convince us you're not trying to get your homework done for you). Post code between [code]...[/code] tags to keep it legible. Also post any error messages you are getting (if any), what input you are supplying to the program, what you expect to happen and what happens instead. Additionally asking a specific question is more likely to get you help.

This page (So, You Need to Write a Program but Don't Know How to Start) has some helpful pointers on how to start on a program. In your case, you find it helpful to think about the following: Given "X", can I write a function that returns "XX"? Given a number N, can I write a function that runs N times?
__________________
sub{*{$::{$_}}{CODE}==$_[0]&& print for(%:: )}->(\&Meh);

Reply With Quote
  #3  
Old October 24th, 2012, 07:32 AM
bandyc bandyc is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 2 bandyc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 19 sec
Reputation Power: 0
Schemer/DrRacket

Thanks OmegaZero. I did change the title in this reply as you suggested and below, to date, is my code.


<code>

(define duple
(lambda (n x)
(if (zero? n) '()
(cons (x)
(duple (- n 1) )))))

(duple 2 5)

</code>

Reply With Quote
  #4  
Old October 29th, 2012, 08:00 PM
Schol-R-LEA's Avatar
Schol-R-LEA Schol-R-LEA is offline
Commie Mutant Traitor
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2004
Location: Norcross, GA (again)
Posts: 1,759 Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 3 h 38 m 3 sec
Reputation Power: 1568
I know this is a few days old, but I figured I might still be able to help, here.

I see a few different problems with the code as written, mainly in that you seem to confuse the two arguments frequently. Perhaps some better names would help...

The biggest problem you'll run into is how you are calling (cons); right now, you are trying to pass it a x in a list (it should be n here, but that's besides the point), but the effect of it is that the interpreter tries to execute a function called 'x', and complains when it can't find one. The correct call form would be

Code:
(define duple
   (lambda (original count)
      (if (zero? count) '()
         (cons original
               (duple original (- count 1))))))
__________________
Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
#define KINSEY (rand() % 7) λ Scheme is the Red Pill
Scheme in ShortUnderstanding the C/C++ Preprocessor
Taming PythonA Highly Opinionated Review of Programming Languages for the Novice, v1.1

FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov

Reply With Quote
  #5  
Old November 15th, 2012, 11:32 AM
bolainmarsh6 bolainmarsh6 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 bolainmarsh6 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 57 sec
Reputation Power: 0
P.S. As more background, I want to be able to do this from the command
line. So that's why I put the question that way. But also, I'm
interested in trying to use Racket from Emacs. At the moment the only
thing I really want now is "get the same thing as pressing F5 in
DrRacket". And (again maybe I'm missing something obvious, or botched
the config) neither Racket nor Geiser seem to provide just quite that.
So I was looking at binding F5 to mode-compile and setting the correct
Racket flags ... that I haven't figured out yet, because apparently
I'm a numskull.

Thank you.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > DrRacket procedure

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap