Beginner Programming
 
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 ForumsOtherBeginner Programming

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 November 6th, 2012, 09:29 PM
just_me1 just_me1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 just_me1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 50 sec
Reputation Power: 0
Application: not a procedure; Dr. Racket(

Hi there! I started studying Dr.racket and I need to produce a list that have first part from a list and the second part from the vector. For example, if I run my program (d '(a b c) '#( 1 2 3))
It should return ((a . 1) (b . 2) ( c . 3)) ;;;. is for pair. So, here is my code:
Code:
(define d
  ( lambda(list vector)
     (define num 0)
     ( d cdr list (vector-ref(vector)num+1))
     ( cons car list vector)))


However, I am getting
Quote:
application: not a procedure;
expected a procedure that can be applied to arguments
given: #(1 2 3)
arguments...: [none]
it complains about (vector-ref(vector)num+1) but I don't understand why... Any help?
Thanks.

Reply With Quote
  #2  
Old November 7th, 2012, 11:01 AM
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
It's because you have extra parentheses around the name vector, which causes the interpreter to treat it as a function of no arguments. That line should read
Code:
     ( d cdr list (vector-ref vector (+ 1 num)))

Mind you, this still isn't correct. First off, the names list and vector conflict with existing function names; try lst and vec instead, or something similar. Second, you need to test whether the list is null, and whether the vector is length zero, before you do any of this, otherwise you'll end up with an infinite recursion. Third, you don't need the num local variable, and even if you did, the correct way to declare a local is with let, not define. Finally, you want to rearrange the recursive call to d so that it comes after where you cons the two first elements together.

I would also recommend looking up the vector-length and vector-drop functions in the Racket documentation, as you'll need them both.
__________________
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

Last edited by Schol-R-LEA : November 7th, 2012 at 11:04 AM.

Reply With Quote
  #3  
Old November 9th, 2012, 03:00 PM
just_me1 just_me1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 just_me1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 50 sec
Reputation Power: 0
Quote:
Originally Posted by Schol-R-LEA
It's because you have extra parentheses around the name vector, which causes the interpreter to treat it as a function of no arguments. That line should read
Code:
     ( d cdr list (vector-ref vector (+ 1 num)))

Mind you, this still isn't correct. First off, the names list and vector conflict with existing function names; try lst and vec instead, or something similar. Second, you need to test whether the list is null, and whether the vector is length zero, before you do any of this, otherwise you'll end up with an infinite recursion. Third, you don't need the num local variable, and even if you did, the correct way to declare a local is with let, not define. Finally, you want to rearrange the recursive call to d so that it comes after where you cons the two first elements together.

I would also recommend looking up the vector-length and vector-drop functions in the Racket documentation, as you'll need them both.

thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > Application: not a procedure; Dr. Racket(

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