New Posts  All Forums:Forum Nav:

lisp help/discussion

post #1 of 31
Thread Starter 
look @ bottom
Edited by protzman - 10/21/12 at 8:40pm
post #2 of 31
Welcome to the Lisp family. thumb.gif

I don't want to give it all away, but here's a couple of hints for some reasonably easy methods. Trial division won't work (of course) because the primitives to do division simply don't exist in Tlisp (I read the page and it only implements a small subset of common lisp). Fermat's method should work. You will need to call it tail-recursively. In addition, a square root method is needed. It should probably recursively call itself. Since you can't divide (and there's no bit manipulators), you will need to have the program take its best guess and square that guess. The guess will then need to be raised or lowered (digit by digit) until the desired precision is reached.

Without division, that's all I've got.

Well... there's another method. Since division is to subtraction what multiplication is to addition, you can check if a number has a modulus by subtracting the number you want to divide by repeatedly. You need to count the number of subtractions and stop when the remainder is less than the number. Multiplying the number by some power of 10 will allow you to add digits of precision (just keep track of how many digits and then subtract it all to get an answer assuming that tlisp converts to floating point numbers).
post #3 of 31
Thread Starter 
.
Edited by protzman - 10/12/12 at 6:21pm
post #4 of 31
Thread Starter 
.
Edited by protzman - 10/12/12 at 6:21pm
post #5 of 31
Thread Starter 
.
Edited by protzman - 10/12/12 at 6:21pm
post #6 of 31
Thread Starter 
Okay so im working on that factors method and its killing me. I have this so far and im dying to figure it out.
Code:
//determines the factors of a number
(defun factors(num)
        (if( equal T (divEven num _______ )))
                //append to ouput list
                


)



//determins if it devides even

(defun divEven ( i j )
  (cond ((= i 0) T)
        ((< i 0) NIL)
        (t (divEven (+ i (* -1 j)) j))
  )
)

what i want is to call factors(8) and get (4 2 1)
I have like the idea of how to do it but just cant figure it out!

please help, i beg of you frown.gif
post #7 of 31
Do you know about recursion?

Just create a factors' function that is called by the factors function that is given two arguments, one the original integer (the one whose factors you want to find) and the other, 1 which is like a factor of any number.
Then, recursively call the factors' function again and again, each time increasing the second argument by 1, checking if the first argument is divisible by it and then appending it to the list of solutions if it is a factor, until the second argument is half of the first argument (use an if conditional to check this).

Basically, you just need to know how to implement recursive solutions to functions.
 
Desktop
(13 items)
 
MacBook Pro 13"
(6 items)
 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
CPUGraphicsRAMHard Drive
Intel i5 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Lion 13.3" @ 1280 x 800 
  hide details  
Reply
 
Desktop
(13 items)
 
MacBook Pro 13"
(6 items)
 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
CPUGraphicsRAMHard Drive
Intel i5 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Lion 13.3" @ 1280 x 800 
  hide details  
Reply
post #8 of 31
Thread Starter 
Thats what i was working on but i couldnt seem to figure out how to make em all work together.
will post back in a few (if you care) with the result or more problems lachen.gif

thanks for the reply
post #9 of 31
Ok so I just went to Google to see what the hell is LISP and I think I misjudged Objective C.

Objective C not the worst language on earth. I think LISP is stun.gif
    
CPUMotherboardGraphicsRAM
Intel 3930K 4.5GHz @ 1.34V Asus rampage extreme IV Shaphire 6950 unlocked to 6970 Corsair Dominators GT 16GB 4GBX4 OCed @ 2400MHz... 
Hard DriveHard DriveOptical DriveCooling
Intel SSD 330 series 180GB WD Black 1TB 64Mb Cache + Blue 500GB 16mb Cache... LG DVD EK-Supreme HF - EN (Nickel) 
CoolingCoolingCoolingCooling
EK-FB KIT RE4 - Acetal Laing D5 Vario 12V DC Pump (MCP 655)  EK-BAY SPIN Reservoir - Plexi EK-CoolStream RAD XT (240) 
CoolingOSMonitorKeyboard
EK-CoolStream RAD XTX (120) Windows 7 64-bit LG W2261 22inch 1920X1080@60Hz Razer Lycosa 
PowerCase
Cooler Master Silent Pro Gold 1000W Thermaltake Level 10 GT 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Intel 3930K 4.5GHz @ 1.34V Asus rampage extreme IV Shaphire 6950 unlocked to 6970 Corsair Dominators GT 16GB 4GBX4 OCed @ 2400MHz... 
Hard DriveHard DriveOptical DriveCooling
Intel SSD 330 series 180GB WD Black 1TB 64Mb Cache + Blue 500GB 16mb Cache... LG DVD EK-Supreme HF - EN (Nickel) 
CoolingCoolingCoolingCooling
EK-FB KIT RE4 - Acetal Laing D5 Vario 12V DC Pump (MCP 655)  EK-BAY SPIN Reservoir - Plexi EK-CoolStream RAD XT (240) 
CoolingOSMonitorKeyboard
EK-CoolStream RAD XTX (120) Windows 7 64-bit LG W2261 22inch 1920X1080@60Hz Razer Lycosa 
PowerCase
Cooler Master Silent Pro Gold 1000W Thermaltake Level 10 GT 
  hide details  
Reply
post #10 of 31
I take it you are Lost In Stupid Parenthesis?
Muzzle Flash
(25 items)
 
Switched Switch
(24 items)
 
Slave Driver
(14 items)
 
CPUMotherboardGraphicsGraphics
Intel i7 3770K Gigabyte GA-Z77X-UP7 EVGA GTX 580 Hydro Copper 2 3GB EVGA GTX 580 Hydro Copper 2 3GB 
RAMHard DriveHard DriveOptical Drive
G.SKILL Trident X  Samsung 840 Pro Seagate Barracuda 1TB 7200 RPM LG Blu-Ray burner 
CoolingCoolingCoolingCooling
Koolance CPU-380I Water Block XSPC RX360 Radiator 6 Cougar CF-V12H fans Alphacool Monsta 360 Radiator 
CoolingCoolingCoolingOS
6 Gentle Typhoon AP-14 fans Twin D5 Dual Bay Reservoir Various Bitspower Compression Fittings Windows 7 Professional 64-bit 
OSMonitorMonitorKeyboard
Ubuntu 12.10 Auria EQ276W 27" IPS HP w2408 Microsoft Natural 4000 
PowerCaseMouseOther
SeaSonic Platinum-1000 NZXT Switch 810 Logitech MX Custom Switch 810 Pedestal by Dwood 
Other
Lots of wire sleeve and heat shrink from MDPC 
CPUMotherboardGraphicsGraphics
Intel 2700k Gigabyte GA-Z77X-UD3H EVGA GTX 560 Ti EVGA GTX 560 Ti 
RAMHard DriveOptical DriveCooling
Samsung DDR3-1600 CL11 Western Digital Caviar Blue 500GB LG DVD Burner XSPC Raystorm CPU Waterblock 
CoolingCoolingCoolingCooling
Durelene 1/2" ID x 5/8" OD Tubing EK-FC560 GTX V2 Waterblock EK-FC560 GTX V2 Waterblock XSPC EX360 Radiator 
CoolingCoolingCoolingCooling
XSPC EX120 Radiator Swiftech MPC655-B D5 Pump XSPC Acetal Top for Laning D5 Danger Den RAD-RES 
CoolingOSMonitorKeyboard
Various Bitspower Compression Fittings Windows 7 Professional Asus VW246H 24" LCD Logitech G110 
PowerCaseMouseOther
Enermax Revolution 85+ 950W White NZXT Switch 810 Logitech M325 NZXT Hue 
CPUMotherboardGraphicsRAM
i5-2500K EVGA Z68 SLI EVGA GTX 560 Ti Corsair Vengeance 16GB 
Hard DriveOptical DriveCoolingOS
Western Digital Caviar Blue 500GB Asus DVD Burner Cooler Master Hyper 212 Plus Windows 7 Professional 
MonitorMonitorKeyboardPower
Dell UltraSharp U2410 Dell UltraSharp U2410 Microsoft Natural 4000 Corsair TX750 
CaseMouse
Cooler Master HAF 912 Logitech MX Revolution 
  hide details  
Reply
Muzzle Flash
(25 items)
 
Switched Switch
(24 items)
 
Slave Driver
(14 items)
 
CPUMotherboardGraphicsGraphics
Intel i7 3770K Gigabyte GA-Z77X-UP7 EVGA GTX 580 Hydro Copper 2 3GB EVGA GTX 580 Hydro Copper 2 3GB 
RAMHard DriveHard DriveOptical Drive
G.SKILL Trident X  Samsung 840 Pro Seagate Barracuda 1TB 7200 RPM LG Blu-Ray burner 
CoolingCoolingCoolingCooling
Koolance CPU-380I Water Block XSPC RX360 Radiator 6 Cougar CF-V12H fans Alphacool Monsta 360 Radiator 
CoolingCoolingCoolingOS
6 Gentle Typhoon AP-14 fans Twin D5 Dual Bay Reservoir Various Bitspower Compression Fittings Windows 7 Professional 64-bit 
OSMonitorMonitorKeyboard
Ubuntu 12.10 Auria EQ276W 27" IPS HP w2408 Microsoft Natural 4000 
PowerCaseMouseOther
SeaSonic Platinum-1000 NZXT Switch 810 Logitech MX Custom Switch 810 Pedestal by Dwood 
Other
Lots of wire sleeve and heat shrink from MDPC 
CPUMotherboardGraphicsGraphics
Intel 2700k Gigabyte GA-Z77X-UD3H EVGA GTX 560 Ti EVGA GTX 560 Ti 
RAMHard DriveOptical DriveCooling
Samsung DDR3-1600 CL11 Western Digital Caviar Blue 500GB LG DVD Burner XSPC Raystorm CPU Waterblock 
CoolingCoolingCoolingCooling
Durelene 1/2" ID x 5/8" OD Tubing EK-FC560 GTX V2 Waterblock EK-FC560 GTX V2 Waterblock XSPC EX360 Radiator 
CoolingCoolingCoolingCooling
XSPC EX120 Radiator Swiftech MPC655-B D5 Pump XSPC Acetal Top for Laning D5 Danger Den RAD-RES 
CoolingOSMonitorKeyboard
Various Bitspower Compression Fittings Windows 7 Professional Asus VW246H 24" LCD Logitech G110 
PowerCaseMouseOther
Enermax Revolution 85+ 950W White NZXT Switch 810 Logitech M325 NZXT Hue 
CPUMotherboardGraphicsRAM
i5-2500K EVGA Z68 SLI EVGA GTX 560 Ti Corsair Vengeance 16GB 
Hard DriveOptical DriveCoolingOS
Western Digital Caviar Blue 500GB Asus DVD Burner Cooler Master Hyper 212 Plus Windows 7 Professional 
MonitorMonitorKeyboardPower
Dell UltraSharp U2410 Dell UltraSharp U2410 Microsoft Natural 4000 Corsair TX750 
CaseMouse
Cooler Master HAF 912 Logitech MX Revolution 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming