This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-03-19 23:04:07

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

List --> equation

I have a list, it contains (for example) 567+9-sinx/5
How do I translate the equation from the list, all into one equation on one block
like this

when I receive [turn into equation v]
put in scripts to help turn into one equation here
set [variable v] to <<[567]+[9]>-<<[sin v] of <x>>/[5]>>
please help!

Offline

 

#2 2012-03-19 23:34:21

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: List --> equation

You're going to have to use a script that looks a little something like this first:

when I receive [turn into equation v]
set [# v] to (0)
repeat (length of (answer))
  change [# v] by (1)
  if <[symbols] contains (letter (#) of (answer))>
    add (letter (#) of (answer)) to [ops v]
  else
    if <(last) = [Num]>
      replace item [last v] of [numbers v] with (item)
    else
      add (letter (#) of (answer)) to [numbers v]
    end
  end
end
Sorry...not quite finished, I have other stuff to do, sorry.  Hopefully this at least helps a bit!

Last edited by AtomicBawm3 (2012-03-19 23:37:05)


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#3 2012-03-19 23:37:12

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

Re: List --> equation

AtomicBawm3 wrote:

You're going to have to use a script that looks a little something like this first:

when I receive [turn into equation v]
set [# v] to (0)
repeat (length of (answer))
  change [# v] by (1)
  if <[symbols] contains (letter (#) of (answer)>
    add (letter (#) of (answer)) to [ops v]
  else
    if <(last) = [Num]>
      replace item [last v] of [numbers v] with (item)
    else
      add (letter (#) of (answer)) to [numbers v]
    end
  end
end
Sorry...not quite finished, I have other stuff to do, sorry.  Hopefully this at least helps a bit!

What does symbols contain?
If someone can please explain this script to me and what it does, that would be helpful. I barely (if not at all) understand the scripts that I already make.

Offline

 

#4 2012-03-20 18:15:09

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

Re: List --> equation

bump

Offline

 

#5 2012-03-20 18:29:23

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: List --> equation

The best way I can describe it is with my own project  tongue . Read the scripts, it's easier programming then reading them though  hmm

Easier to understand

Harder to understand

Last edited by laptop97 (2012-03-20 18:30:55)

Offline

 

#6 2012-03-20 18:39:44

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

Re: List --> equation

Thank you, I'll bump again if I don't know what to do.

Offline

 

#7 2012-03-20 20:19:24

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: List --> equation

Symbols would be a preset list you make containing the items:
+
-
*
/
^
(
)
then you can label each symbols "importance" in another list for PEMDAS to work...sorry, it's complicated, but could work.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#8 2012-03-20 23:52:47

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

Re: List --> equation

I actually found a method (using laptop97's project). It will be based off of that, but a little more complicated since I am building a "grapher" project that one of the options for a graph is an equation.

Offline

 

#9 2012-03-21 21:49:06

TorbyFork234
Scratcher
Registered: 2012-03-01
Posts: 1000+

Re: List --> equation

Well, using an idea from laptop97's project I was able to finish one part of it. You can look at it here. Although some of the scripts will be kind of hard to understand.

Offline

 

Board footer