Message Boards Message Boards

0
|
2809 Views
|
8 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Can we set some parameters to increase the indentation?

Posted 1 year ago

Hello, everybody! I am a beginner to Mathematica. When I write looping construct codes in the Notebook of Mathematica. I want to use the Python style. When I press Enter after an uncompleted function to start a new line, I found there is about a character size indentation. But I feel a character size indentation is not enough. Are thenter image description here some parameters in Mathematica need to be set to modify this indentation? How to set it?

POSTED BY: Q Wang
8 Replies
Posted 1 year ago

Thank you very much! A good advice!I will try my best to learn the functional approach. It is the Wolfram Language (WL) way, the elegant style.

POSTED BY: Q Wang

Hi Q,

If you are new to the Wolfram Language (WL) I suggest you try not to use "Python style" to write WL code. Rather than transcribing procedural Python code to WL, use a functional approach instead. Here is a functional implementation

f[x_] := x - Exp[-x];
x0 = 0.5;
ϵ = 1.*10^-8;

NestWhileList[(# - f[#]/f'[#]) &, x0, ϵ < Abs[#1 - #2] &, 2]
POSTED BY: Rohit Namjoshi
Posted 1 year ago

Thank you very very much! You give me the right way!

POSTED BY: Q Wang
Posted 1 year ago

Thank you very very much! You give the right way. It is just what I want.

POSTED BY: Q Wang
Posted 1 year ago

Try using the Tabs key to indent a new line

POSTED BY: Hans Milton
Posted 1 year ago

There is a LineIndent option. You can set it via the option inspector or you can set it via stylesheets.

POSTED BY: Eric Rimbey
Posted 1 year ago

Thank you for your reply! But I can only adjust the total indention of the cell. Would you like to tell me how to make it like the Python indention style when I start a new line?enter image description here

POSTED BY: Q Wang

In the menu 'Windows/Toolbar" activate the Ruler. You can adjust indention by cell type.

POSTED BY: Roland Franzius
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract