Post Reply 
Simple challenge in RPL, Extract the odd elements from a list
08-16-2017, 12:28 PM (This post was last modified: 08-16-2017 08:29 PM by compsystems.)
Post: #1
Simple challenge in RPL, Extract the odd elements from a list
Extract the odd elements from a list, with commands: SUB, MAP, AXL, TRAN others

example https://www.mathworks.com/help/symbolic/factor.html

with FOR cmd
PHP Code:
«
  
'F' STO
  1 
'K' STO
  0 
'S' STO
  
{ } 'L' STO
  F SIZE 
'S' STO
  1 S
  
FOR
   
K F K GET 'L' STO+
   
2
  STEP
  F
  L REVLIST
» 
example1
input:
'x^4-1' FACTORS
{ 'x+1' 1. 'x-1' 1. 'x+i' 1. 'x-i' 1. }
output
{ 'x+1' 'x-1' 'x+i' 'x-i' }

example2
input:
'x^4+x^3-6*x^2-4*x+8' FACTORS
{ x-2, 1,x-1, 1, x+2, 2 }
output
{ x-2, x-1, x+2 }

With SEQ cmd
PHP Code:
«
 
'F' STO
  
'K' PURGE
  F SIZE 
'S' STO
  « F K GET »
  K
  1
  S
  2
  SEQ 
» 
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Simple challenge in RPL, Extract the odd elements from a list - compsystems - 08-16-2017 12:28 PM
RE: Simple challenge in RPL - compsystems - 08-16-2017, 12:54 PM



User(s) browsing this thread: 1 Guest(s)