New Posts  All Forums:Forum Nav:

# lisp help/discussion

look @ bottom
Edited by protzman - 10/21/12 at 8:40pm
Welcome to the Lisp family.

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).
.
Edited by protzman - 10/12/12 at 6:21pm
.
Edited by protzman - 10/12/12 at 6:21pm
.
Edited by protzman - 10/12/12 at 6:21pm
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!

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.
 MacBook Pro 13" (6 items) Toshiba Satellite L655 (13 items) Desktop (13 items)
CPUGraphicsRAMHard Drive
Intel i5 3210 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM
OSMonitor
OSX Mountain Lion 13.3" @ 1280 x 800
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
 MacBook Pro 13" (6 items) Toshiba Satellite L655 (13 items) Desktop (13 items)
CPUGraphicsRAMHard Drive
Intel i5 3210 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM
OSMonitor
OSX Mountain Lion 13.3" @ 1280 x 800
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
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

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
 My Black and Red Rig (29 items)
CPUMotherboardGraphicsRAM
Intel 3930K 5040MHz @ 1.48 - 1.53v @ VTT/VCCSA ... Asus rampage extreme IV Gigabyte GTX 970 G1 @ 1580/4050MHz @ 1.325V Corsair Vengeance 64GB (8 x 8GB) DDR3 2400MHz. ...
Hard DriveHard DriveHard DriveHard Drive
Samsung 850 Pro 256GB Seagate Barracuda ST3000DM001 3TB WD Black 1TB 64Mb Cache  WD Blue 500GB 16mb Cache
Hard DriveOptical DriveCoolingCooling
WD Black 4TB 64mb Cache LG DVD EK-FB KIT RE4 - Acetal EK-FC970 GTX WF3 Backplate - Black
CoolingCoolingCoolingCooling
Laing D5 Vario 12V DC Pump (MCP 655)  EK-BAY SPIN Reservoir - Plexi EK-CoolStream RAD XT (240) EK-CoolStream RAD XTX (120)
CoolingCoolingCoolingCooling
EK-CoolStream XE 120 (Single) 8x Corsair Air SP120 PWM High Performance Edition 3x Corsair Air AF120 High Performance Edition EK-Supremacy EVO CPU Water Block (Nickel Acetal)
CoolingOSMonitorMonitor
EK-FC970 GTX WF3 - Acetal+Nickel Windows 10 64-bit v1511 build 10586.14 BenQ RL2755HM LG W2261
MonitorKeyboardPowerCase
Samsung S23C350 Razer BlackWidow Ultimate Cooler Master Silent Pro Gold 1000W Thermaltake Level 10 GT
Mouse
Razer Lachesis 5600DPI
 My Black and Red Rig (29 items)
CPUMotherboardGraphicsRAM
Intel 3930K 5040MHz @ 1.48 - 1.53v @ VTT/VCCSA ... Asus rampage extreme IV Gigabyte GTX 970 G1 @ 1580/4050MHz @ 1.325V Corsair Vengeance 64GB (8 x 8GB) DDR3 2400MHz. ...
Hard DriveHard DriveHard DriveHard Drive
Samsung 850 Pro 256GB Seagate Barracuda ST3000DM001 3TB WD Black 1TB 64Mb Cache  WD Blue 500GB 16mb Cache
Hard DriveOptical DriveCoolingCooling
WD Black 4TB 64mb Cache LG DVD EK-FB KIT RE4 - Acetal EK-FC970 GTX WF3 Backplate - Black
CoolingCoolingCoolingCooling
Laing D5 Vario 12V DC Pump (MCP 655)  EK-BAY SPIN Reservoir - Plexi EK-CoolStream RAD XT (240) EK-CoolStream RAD XTX (120)
CoolingCoolingCoolingCooling
EK-CoolStream XE 120 (Single) 8x Corsair Air SP120 PWM High Performance Edition 3x Corsair Air AF120 High Performance Edition EK-Supremacy EVO CPU Water Block (Nickel Acetal)
CoolingOSMonitorMonitor
EK-FC970 GTX WF3 - Acetal+Nickel Windows 10 64-bit v1511 build 10586.14 BenQ RL2755HM LG W2261
MonitorKeyboardPowerCase
Samsung S23C350 Razer BlackWidow Ultimate Cooler Master Silent Pro Gold 1000W Thermaltake Level 10 GT
Mouse
Razer Lachesis 5600DPI
I take it you are Lost In Stupid Parenthesis?
New Posts  All Forums:Forum Nav:
Return Home
Back to Forum: Coding and Programming