Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.3K Views
|
2 Replies
|
1 Total Like
View groups...
Share
Share this post:

Create a function that takes two parameters and returns one output?

Posted 9 years ago

Hello Wolfram Community,

I have a function that takes two parameters and is essentially supposed to return one of two things: "line Crossed" or "no line Crossed". However with this current function I am getting Null as my output. Why is this and how can I achieve my desired output. Here is the code:

needleCross[length_, distance_] := {
  Block[
   {midPoint = RandomReal[distance], 
    rotationAngle = RandomReal[{-Pi/2, Pi/2}]},

   xCoordLinePoints = {midPoint - (Cos[rotationAngle]*length/2), 
     midPoint + (Cos[rotationAngle]*length/2)}];

  If[xCoordLinePoints[[1]] <= 0 || xCoordLinePoints[[2]] >= distance, 
   Print["Line Crossed"], Print["No Line Crossed"]]}

any advice would help!

Thanks

POSTED BY: Anders Khaykin
2 Replies
POSTED BY: Marco Thiel

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

The rules explain how to format your code properly. If you do not format code, it may become corrupted and useless to other members. Please EDIT your posts and make sure code blocks start on a new paragraph and look framed and colored like this.

int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]

enter image description here

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