[ art / civ / cult / cyb / diy / drg / feels / layer / lit / λ / q / r / sci / sec / tech / w / zzz ] archive provided by lainchan.jp

lainchan archive - /λ/ - 2

File: 1492025656234-0.png (856.23 KB, 300x225, img_3662.jpg)


This is the Beginner's General for beginner's questions.

If you have a simple question and a suitable thread doesn't already exist, just post it here and someone will probably try to answer it for you.

Remember to do some research before asking your question. No one wants to answer a question that a simple search can already resolve.


File: 1492030879754.png (10.47 KB, 170x200, Android_robot_2014.png)

This isn't really a beginners question but I don't think it warrants its own thread.

What's the best (read: least annoying) way to build Android apps right now?
I'm looking to build a fairly simple CRUD app but after reading through a bit of the official documentation of the Java API, I don't really feel like touching that if I don't have to.


For CRUD, Android ha a fairly straiforward SQLite implementation. Same for reading and writing files. Of course it depends on what you want to do.


>What's the best (read: least annoying) way to build Android apps right now?
Use an implementation of a language that supports Android development.

Ideally, the Android-specific parts would be very small compared to the actual logic of the program.


>>15 here. Thanks for all the answers.
I decided to just go with the standard Java Implementations because my app is mainly GUI anyways.


I have no programming background, although I know how to admin a unix server.

I want to learn it, especially some scripting language such as Lua.
I've tried it. No success because I think the way people teach programming is wrong. I don't want to know the syntax as the first thing, I want to understand the basic structure of a program and know, in a macro way, what's going on.

So, any of you can recommend any way I can learn some scripting language in a way that does not focus only on syntax? I have tried some, including "thehardway" stuff, and also the original Lua tutorials. No success.
The "prototyping" way to learn seems good, like, doing a basic program, instead of learn the syntax. Much more sense to me.

Just as a hint, before people start: I don't consider myself dumb. I can learn most of the things easily, but programming hit me on the nerves for reasons that I don't agree with the teaching method generally used.


Unfortunately, it seems the languages that focus on syntax the least also aren't what most would call scripting languages.

It doesn't stop me from scripting with Lisp, but it's questionable if you'd want to.


what I did was setting a goal (in my case, an irc client) and just trying to create it, failing horribly, learning from my mistakes and restarting. it's what I recommend to most people, because reading how to program in a book or tutorial is not gonna stick. you gotta get hands on experience. best of luck, lainon!


if you are comfortable with Unix then why not dig a little deeper with shell scripting? think of it like learning about your tools while your on the job. in the long run maybe even take a look at languages like sed, AWK, or perl 5?


File: 1492076835043.png (46.43 KB, 176x200, golang.jpg)

I am not really a beginner, but I did not want to create a thread for my nonfactual question.

I have experience with Java and Haskell , I am also able to understand Python code well, but I don't really like writing or working with Python.
I am also looking into Rust.

I want to dive into a new fun language that is...for the lack of a better word...a bit more "common", I hope you understand what I mean.

Go seems really interesting to me, but since it is tied to Google and some comments here about how it is a harmful language scared me away.

I know that questions like this are hard/impossible to answer, but what do you think about Go? Do you think it's worth learning in my case?


If you want to learn anything new, you won't get that from Go. Go is pretty much a subset of Java, feature wise.
The only "new" thing that it has going is the concurrency stuff, but Haskell has already had that for a long time. (If you're interested in that, I'd recommend http://chimera.labs.oreilly.com/books/1230000000929 , which you can read for free on the O'Reilly website)
Go really just doesn't have much going for it. Depending on where you live, there might be a few jobs offerings, but that's about it.


File: 1492079381127.png (3.89 KB, 200x115, image002.png)

Request advice on 8086 assembly.

I have been using Linux in my daily life for more than 6 years. I began with Python and later mastered an intermediate skill of Unix C programming (e.g. have spotted and sent patches to fix off-by-one errors in some basic system tools).

But I haven't touched any underlying deeper things beyond C, my assembly skill is limited to writing C wrapper functions for embedded system calls. I tried to learn assembly twice but it's too painful for me to get started, Is there a modern tutorial for starters like me? I really need to know assembly because of my infosec interests.


looking for suggestions for programming exercises, outside of standard operating principle of working towards a project

i have some projects i'd like to work towards, but in the meantime i'd like to supplement my formal education with some challenges to keep myself sharp, self-assess learning, and round-out my skill set

ie, more like this:

(unfortunately, for reference, the language i am learning is java)


There's the 99 Prolog Problems, derivatives of which are available in various languages (so you should be able to port the spirit of the questions to Java.

- Prolog: http://www.ic.unicamp.br/~meidanis/courses/mc336/2009s2/prolog/problemas/
- Lisp: http://www.ic.unicamp.br/~meidanis/courses/mc336/2006s2/funcional/L-99_Ninety-Nine_Lisp_Problems.html
- Haskell: https://wiki.haskell.org/H-99:_Ninety-Nine_Haskell_Problems

Having worked professionally with Go for a summer, I agree with >>95. You probably won't learn anything new, and much of the language is frustrating, but it's a good one to learn currently if you're looking for a job and don't mind writing something only slightly higher-level than C.
I don't think it being tied to Google is really a problem. It's in their financial interest to make the language as widespread and popular as possible, as then they need to do less training for future hires.


neato, these look totally outside of my ZPD at the moment, but seem like they're useful. will tackle them when they're within reach of my skillset.


What text is being shown in https://lainchan.org/λ/res/1.html ?

>programming exercises



As a newbie programmer to another, what I started with has worked well for myself and many others: https://www.cs.cmu.edu/~dst/LispBook/book.pdf - The reason for this book is because I believe as a beginner, one needs structure and lots of problems. See http://lisp-lang.org/learn/getting-started/ for setting up an appropriate Lisp environment.



Thanks for your opninions. The fact that it's not far away from C is actually what makes it interesting to me. But then again, I might as well just learn C.

However learning a comfy language I might find a job with is also a factor, as well as getting the option to contribute more to other projects, and the other way around.


Thanks for making the thread. I've been programming with things like Python and Perl for a while now and I'm starting to get good at basic syntax and program structure. I'm not sure where to start learning assembly and would love to get into some more high level stuff. Any suggestions?


Could someone recommend an open-source project that has
1. Well-written, idiomatic C++ code that would be good for a beginner to learn from; something that you would consider a benchmark in code quality for C++
2. Good design
3. Good documentation


There aren't many good resources on assembly language, but it depends on what you want to use it for. Do you just want to learn how things work under the good, be able to understand a disassembly or assembly listing, or actually want to write assembly language for something?
For example, if you're interested in learning how machines work at the low level in general, or to do low-level tricks, then perhaps some other architecture (ie, not x86) would be best. Some 8-bit or 16-bit architecture, something like CHIP-8 or C64 assembly.

On the other hand, for high-level languages: Haskell and Lisp are the most interesting high level languages.


MIPS is always popular for learning assembly, there are also books that updated to ARM.

"Computer Organization and Design" by Patterson/Hennessy comes to mind. I did not read it myself though.

As >>135 pointed out, assembly learning resources are most often tied to computer hardware/architecture.


Does anybody have a good top-down 2d car physics example?


I have so many questions
(I'm a barebones beginner)

>How can i start learning Lisp?

>Any good book to start with C?
>Should i learn Python? And why?
>Why does many people loves java?
>Does anyone knows about COBOL?



glad to see more assembly posts. I'm the first assembly poster, sorry for the insertion.

I want to learn assembly to understand vulnerabilities and memory exploitation techniques, because I'm interested in attacks and compiler hardening around C code.


I have the same thought, modern amd64 is a clusterf**k architecture that has been filled as many instructions as possible for practical reasons and clearly not good for a beginner (like me).

MIPS sounds good and I have a box. But I don't know if it's easy to migrate the knowledge back to amd64 since most exploitation occurs on x86/amd64.



>How can i start learning Lisp?

Lisp syntax is the easiest to learn of any language. But Lisp is the hardest language to master. Any Lisp book will easily teach the basic syntax

>Any good book to start with C?

"C Programming: A Modern Approach" by King

>Should i learn Python? And why?

you should know at least one general purpose scripting language, Python and Ruby are the most popular. I recommend staying away from Perl unless youre going to be a sysadmin.

>Why does many people loves java?

Java is the most basic language everyone understands, there is no weird or unusual syntax, everything works like you would expect. So its the perfect language for when you have thousands of programmers who all have to make software integrate together

>Does anyone knows about COBOL?

no one uses it for new software, you can make a lot of money maintaining legacy COBOL software


>I want to learn assembly to understand vulnerabilities and memory exploitation techniques, because I'm interested in attacks and compiler hardening around C code.

Then you want to read "Hacking, the art of exploitation". It covers that and gives a good paced introduction (plus practice) in reading assembly.

On the topic of migrating your knowledge, if the case were that you wanted to learn to /write/ assembly (and do some cool bit tricks with it), then porting your knowledge would be the least of your problems. First learn2assembly, have fun (very important), and then migrating to a new architecture shouldn't be much of a problem.


>How can i start learning Lisp?
Common Lisp: A Gentle Introduction to Symbolic Computation (freely available through a web search)
>Any good book to start with C?
K&R. It's old, but the best introduction so far.
>Should i learn Python? And why?
Maybe. Python is a very dull language, and you don't really need to learn it. Also don't worry about should or shouldn't. Start with one language, learn to use it to solve problems, and don't worry about the rest of the world for now.
>Why does many people loves java?
>Does anyone knows about COBOL?
If you want to land a safe job mantaining antediluvian code, it's okay, but it's very rare as well. For anything else, it belongs to a museum

Again, learn one language, solve problems with it, don't worry about the world. Racket is a nice language to start, but Common Lisp is very much okay too.

>Lisp syntax is the easiest to learn of any language
>Java [...] there is no weird or unusual syntax
Do you see the contradiction?


I'm doing an exercise from K&R, the book gave me a program that converted fahrenheit to celsius and the exercise is taking that program and making one that does the opposite, converting celsius to fahrenheit.

So far my program compiles successfully but when i run it it sticks in a loop with the same numbers over and over again.

  #include <stdio.h>

float fahr, celsius;
float lower, upper, step;

lower = 0;
upper = 300;
step = 20;

celsius = lower;
while (celsius <= upper) {
fahr = 32.0;
celsius = 5.0/9.0; /* on the original program these variables were not written like this */
fahr * celsius;
printf ("%6.0f %3.1f\n", celsius, fahr);
celsius = celsius + step;


>celsius = 5.0/9.0;
Here's the problem. celsius is set to 5.0/9.0 at each step, so at the end (and before the test 'celsius <= upper') the value is 5.0/9.0 + upper, a constant (ie, always the same).
>fahr * celsius;
This doesn't accomplish anything, it's wasted computation (the value isn't stored anywhere).


i had some issues working through these same exercises. alongside the helpful advice from >>231 it's also useful to keep in mind that your calculation will want to involve both fields - storing the value in one field on one side of the equation, and modifying the value of one field with each step in the other.

as a complete novice and non-mathematically inclined individual when i was working through these exercises, it took me a few tries. keep at it, you'll figure it out.


What C/C++ IDE does Lainchan use?


I've never personally used one. I'd suggest just using the command line and makefiles.


>at the end (and before the test 'celsius <= upper') the value is 5.0/9.0 + upper
Obviously you meant "+ step". Were it "+ upper" it would at least terminate.


File: 1492204849535.png (45.81 KB, 134x200, 9781466593367.jpg)

fuarrrk this, now I'm going to read pic related


I have no personal experience, but a name user from ages past once said that disassembling small c programs is useful for learning assembly, and specifically for learning how real code translates into assembly


Is Sicp still the best book for a beginner ?


Not at all. Don't let memes convince you of that, because it's an incredibly difficult book.


could you suggest an alternative?
also mentioning that sicp is a difficult book for a beginner is it worth coming back to it ?


Im not that guy, but if you want to learn Scheme the best, clearest and most direct book is "The Scheme Programming Language" which you can read for free online


I am going to disagree with the other two guys.
Start with The Little Schemer, it's fun, and it introduces Scheme nicely.
TSPL is a huge book for a small language. It is too verbose, and it's too expositive.
People like calling SICP a meme, but it is actually a really good book and makes you thing, It's not at all easy, but you don't really need any prior knowledge to read it. It is not a Scheme book, it just happens to use Scheme. It is a book about computation, which explores it in a mathematical way. Note that by computation I don't meant programming, it's a heavily theoretical book.


Thank you, but i am aware of what you mentioned,the sicp book was recommended to me as an intro to cs but i am not too confident in my math skills,so i was looking for other books to ease up the learning curve


Just don't go learning calculus or something like that, it has almost no use (or perhaps none at all) in CS. I say this because I've seen people somehow think that calculus has anything to do.
I really don't know what I'd tell you to look into, maybe just sharpen your logical thinking skills.


i'm happy to share with you some pseudocode to help structure your thoughts around this

hint: including your printf statement, you can do the entire calculation within the loop in three lines:
print statement
adjustment of iterated field

you can actually do it in a single print statement, which is one of the following exercises iirc

keep at it!


Lainons, I know this is a lowly request, but I'm stuck on an assignment and am not sure how to proceed.

Here is the instructions.
b.) Create a class named TestLease whose main() method declares four Lease objects. Call a getData() method three times. Within the method, prompt a user for values for each field for a Lease, and return a Lease object to the main() method where it is assigned to one of main()'s Lease objects. Do not prompt the user for values for the fourth Lease object, but let it continue to hold the default Values. Then, in main(), pass one of the Lease objects to a showValues() method that displays the data. Then call the addPetFee() method using the passed Lease object and confirm that the fee explanation statement is displayed. Next, call the showValues() method for the Lease object again, and confirm that the pet fee has been added to the rent. Finall, call the showValues() method with each of the other three objects; confirm that two hold the values you supplied as input and on eholds the constructor default values. Save the application as TestLease.java

Here is what I have come up with.

  import java.util.Scanner;
public class TestLease {
public static void main(String args[]){
Lease lease1 = new Lease();
Lease lease2 = new Lease();
Lease lease3 = new Lease();
Lease lease4 = new Lease();
lease1 = getData(lease1);
lease2 = getData(lease2);
lease3 = getData(lease3);


public static Lease getData(Lease l)
Scanner input = new Scanner(System.in);
System.out.println("Please enter the tenants name: ");
String name = input.nextLine();
System.out.println("Please enter the apartment number: ");
int num = input.nextInt();
System.out.println("Please enter in the rent amount: ");
double rent = input.nextDouble();
System.out.println("Please enter in the length of the lease agreement: ");
int length = input.nextInt();
return l;
public static void showValues()



what i'm having an issue with is defining the showValues() method. I have tried every call to getData(), and every passed argument, as well as combinations thereof, that I can think of. I should point out that the current construction, with the unknown variable l passed to getData, is just a placeholder. I'm aware that a Lease object is required, but I can't figure out how to correctly pass it.

I have a feeling the solution is fairly obvious, but I'm failing to see it at the moment, and am requesting that some kindly lainon could provide an example of how they'd structure that method, as well as an explanation. Now, I don't want the homework done for me, I'm just stuck on this part and would benefit from seeing a demonstration. I can figure out what knowledge I was lacking from there, and rectify that lack of understanding.

Thanks in advance.



> [...] declares four Lease objects

You did not only declare them but you've also created aka defined them. You have to create new Lease objects in the getData() method and return the newly created objects so you can assign them to the declared variables; getData does not need any parameter.

Your showValues on the other hand needs a parameter, you have to pass a Lease object to it to be able to access and print its attributes.

I think it might help you to look at the first few chapters of the official java tutorial again, I have the impression that you have to consolidate your grasp of some basic principles as well as basic terminology (what's a reference aka pointer to an object? what's a declaration? etc.)

I think you can learn this stuff, just sit down for a few hours to "relearn" Java and I'm confident you'll be able to do it.


Thank you for your excellent and helpful feedback. I'll admit that I skimmed this chapter - focusing on examples - due to time constraints, which made this assignment far more difficult than it needed to be.
I will go back and review the chapter in detail.

After reading and working on it, I managed to fulfill the requirements of the assignment:
  import java.util.Scanner;
public class TestLease {
public static void main(String args[]){
Lease lease1;
Lease lease2;
Lease lease3;
Lease lease4 = new Lease();
lease1 = getData();
lease2 = getData();
lease3 = getData();


public static Lease getData()
Scanner input = new Scanner(System.in);
System.out.println("Please enter the tenants name: ");
String name = input.nextLine();
System.out.println("Please enter the apartment number: ");
int num = input.nextInt();
System.out.println("Please enter in the rent amount: ");
double rent = input.nextDouble();
System.out.println("Please enter in the length of the lease agreement: ");
int length = input.nextInt();
return new Lease(name,num,rent,length);
public static void showValues(Lease l)
System.out.println("Tenant name: " + l.getName());
System.out.println("Apartment number: " + l.getApt());
System.out.println("Monthly rent: " + l.getRent());
System.out.println("Length of lease: " + l.getLease());


Does anybody knows about a good call spoofing service? (if its free, go ahead with it)
I'd want to improve my social engineering skills
(I KNOW, I KNOW, This is /lam/ but as we don't have /sec/ right now, im feeling forced to post it here)


Does anyone have good resources for learning to develop for the web? I'm thinking of a project along the lines of a small text-board or something.
Most of what I come across is absolute beginner material that doesn't really explain anything. I can already programme and know the very basics of html/css/js, but I'm not really sure where to go from here.



I'm working through Stroustrup's PPP2, and I've run into a snag in the exercises for chapter 9. I have this code here:
  int main()                                          
Library l;

Book b1 {"1-2-3-4","gubbinz","james bond",Date{

Patron p1 {"james", "12345678"};
Patron p2 {"billybob", "87654321"};


vector<string> users_in_debt;
cout << users_in_debt.size() << '\n';

return 0;

If I make these changes
  Patron p1 {"james", "12345678"};   
Patron p2 {"billybob", "87654321"};

I.e., If I move the calls to set_fees_owed() until after the calls to add_patron(), the change in fees doesn't get carried over to the representations of p1 and p2 inside the Library object l.

As a result, the call to users_in_debt() returns an empty vector. I'm passing the patrons to add_patron() as references, and what I'm expecting that to do is to make any changes I make to p1 and p2 carry over to those internal references. Where am I going wrong here?


>returns an empty vector
Bad wording; it obviously doesn't return anything.
Here are the files if it helps:






The reason why SICP is a meme, is partly because its authority, and of course, difficulty.

The level of the book is not really high, but the point was MIT used to teach this in the fist semester for computer science courses, and it was quite difficult for newcomers without background to catch up...


I'm having some problems understanding TDD, Lain. I understand the principles behind the theory, not the implementation.

The basic structure is that i write a test, watch it fail, then write the code so the test passes. But let's say i'm making a unit conversion program (kg to pound etc), if i write a test for "input 1kg, output xpounds", that test will certainly fail, but to make it work i would need to write a whole structure behind it.
I would need to sanitize the input, convert the values and process the output. Should these be tested, too? And if they should, wouldn't that kill the whole workflow? Since the idea is test -> fail -> write -> test. In this scenario, i would test -> fail -> write -> fail -> write a bunch more tests and code so i can recursively make the first test work -> test.

Using this example of a unit conversion, how would you go about it with TDD?


You have to write the simplest possible code to pass all the tests so far. So if your only test is 1 kg -> 2.205 pounds, your code should just constantly return with 2.205. Then you write the next test which will fail your code (for example, 2 kg is not 2.205 pounds), and repeat this cycle until you are satisfied with the tests and the code.

You would only write the input sanitization once you have at least one test that actually needs the input to be sanitized, and should end up with separate test cases for all the errors possible in the input.


What's to be gained from that approach, though? I understand the advantages of writing a test first, but writing a test that expects `1kg -> 2.205 pounds`, in which the code consists of `return "2.205 pounds` isn't just a waste of time? I gain no insight in the requirements of the project, nor am i covering a larger area of the system with tests.


It's Rechnender Raum or Calculating Space by Konrad Zuse. This is in the filename.

Emacs is my environment, although I don't program in C or C++. Vim is also popular.

I'm a different individual and I've never heard of this approach but already question its validity.

For converting between units, have a base unit (typically metric is used) and define units in terms of others declaratively. Then, there'd be no need to test if it worked correctly in an automated fashion, as the system would simply be told that a pound is 0.45359237 kilograms and similarly that one pound is sixteen ounces and so on.

Any flaw in your program would then indicate a flaw in the declarative machinery or the data your system is using. If all the system does to convert is multiply and whatnot, that would be hard to get wrong, generally.

If this didn't help, just ask differently.


But the point of the question isn't to create a unit conversion program, it's to understand TDD specifically.


You end up with minimal code that's guaranteed to be fully covered by tests. Every part of your code can be justified by pointing to the test that makes it necessary.

Or something like that, I'm not sure if anyone actually does it this rigorously.


No SICP is really good but might be to hard to start with.
There is How to design programs if you find SICP to hard.

Anyway you can always look here https://teachyourselfcs.com/


I "fixed" it, but I don't know how.

If I modify p1 in main, that change doesn't get carried over to its representation in the vector inside the Library object. If I make a function that returns a reference to the representation inside that vector, and then make a change to that, that _does_ get carried over to p1 in main.

I still don't understand how references work, but at least the program "works" now and I can move on.


What is some really good computer science knowledge that is not natural to come across, Lain?

For example, i knew a lot of the concepts in SICP before reading it, because most functional programming books/classes already teach them. So i dropped the book after the first chapter and reading the second (without doing the exercises).
This happens often, most books try to be geared towards beginners (probably to sell for more people), and the same can be said for courses.

I'm at a point in my career as a programmer where i don't know where to grow to. I don't feel like i'm good enough to do good things, but i also don't know what i could be doing better/learning.


You can always Go Deeper(tm).


If you already know well the lambda calculus and denotational semantics, you could go into category theory and type theory. Proof theory also has some results that are interesting for the computer science.
But those are all theoretical subjects. If what you want is some advanced /programming/ techniques, then perhaps just start doing lisp macros. Read On Lisp, or Let Over Lambda, and you could also take a look into Art of the Metaobject Protocol.


Anons, i've made a linked list in C and as a challenge for myself i've made several functions using loops and recursion. The problem is that i couldn't develop the remove function recursively, and i also couldn't find any legible code for this function on google. Can you guys help me?

Not sure if it'll help, but here is the code for non-recursive removal:

  struct list* remov(struct list *head, int number){
struct list *previous = NULL, *current = head;

while (current->number != number && current != NULL){
previous = current;
current = current->next;

if (current != NULL){

if (current == head){
head = head->next;

previous->next = current->next;

return head;



This is my attempt: http://0x0.st/xOG.c

I'll comment it later


sorry that last line shouldn't be return remov(...), it should be remov(...); return head;

my bad


Ok here's my attempt to comment out the remove implementation. https://p.memenet.org/fb1d5a

I also just implemented the rest of the linked list so that I could run my tests.


Thank you, anon!
if i understand correctly your function is deleting a node based on its index inside the list, right? i didn't tried that heh

But still, what its the void pointer inside the node?


I'm still stuck on the same K&R exercise.
I know fahrenheit is 17.22 celsius and celsius 33.8 fahrenheit but I don't know how to represent that on the operation.
My program compiles correctly but sticks in a loop.

  #include <stdio.h>

float fahr, celsius;
float lower, upper, step;

lower = 0;
upper = 300;
step = 20;

celsius = lower;
while ( celsius <= upper)
fahr = (15.0/17.0) * (celsius-40.0);
printf("%3.0f %6.1f\n", celsius, fahr);
fahr = fahr +step;
The fahr = (15.0/17.0) * (celsius-40.0) is the issue here and I have no idea how to properly write this operation.


your loop is not iterating Celsius. The while is waiting for Celsius to be greater than upper but Celsius is remaining at 0.


Just data associated with each element. If you just wanted to store a linked list of integers you can do without it. But later on in data structures, when you're doing binary search trees or skip lists or something, each node will have a key and a value on it, key is your "number", value is my "data" pointer. So then you could set the key to something like an employee ID number and the data pointer to a big employee record. Then when you need to look up an employee by their ID number in log(n) time, you can use a tree. When you find the node in the tree with the right ID number, just use that_node->data to get the whole employee struct with more stuff like their name, phone number, etc... that you don't want to store in each node. Plus you can then use the same tree code to hold other types of data without writing a new node struct


>sticks in a loop
The reason is here >>575 and the final increment was already correct in >>228 so there was no need to change it. The constants involved in the conversion were also correct in >>228 so there was no need to make up bogus new ones. If you need the formula handed to you your search engine of choice will do that.


Why does this PAREN-DEPTH work? I can't see the underlying logic.

(defun paren-depth (list)
(if (atom list) 0
(max (+ 1 (paren-depth (car list)))
(paren-depth (cdr list)))))

I can take a simpler reduced form of this which just counts cons cells, COUNT-CONS. It's quite straightforward as something that isn't an atom is a cons cells (with our expect input), and so we add 1 until we get an atom for each recursive call.

(defun count-cons (x)
(if (atom x) 0
(+ 1 (count-cons (car x))
(count-cons (cdr x)))))


Okay I changed the line to :
celsius = (5.0/2.0) * (fahr-32.0);
the program compiles but when ran it only shows a pair of very long numbers.
There is probably something I'm not taking into account.


go line by line through your program line by line and ask why that line is there and find the answer. why include stdio.h? what does float mean? how does it compare to int? what is a while loop and why do you use it? what is printf and where does it come from? what do you want your program to output? what is it outputting? why do you think the error is with the line that you think its on.

you seem to be guessing on how to fix the program, stop doing that. once you understand the problem you can form a solution.